评论

收藏

[JavaScript] 【Web】Javascript、Python、Django模板配合处理URL Encode

开发技术 开发技术 发布于:2021-07-23 17:02 | 阅读数:432 | 评论:0

1、JS
function relaunch(id, service, submit) {
var username = $("#id_username").text();
/* if (submit != username && submit != "null") {
addAlert("Warning: " + "Permission Denied, Only Your Private Deploy Allowed To Relaunch !");
return false;
} */
window.location = '/deployNext/?type=redo&deploy_id='+id+'&service='+encodeURI(service);
}
2、Python
>>> from urllib import quote
>>> quote('魔兽')
'%C4%A7%CA%DE
3、Django模板
<ul class="dropdown-menu">
<!-- <li><a href="/newJobBasic/">Basic</a></li>
<li><a href="/newJobScript/">Script</a></li>
<li><a href="/newJobPlaybook/">Playbook</a></li> -->
{% for item in tmp_keys %}
<li><a href="/deployNext/?type=new&service={{item | urlencode}}">{{item}}</a></li>
{% endfor %}
</ul>




关注下面的标签,发现更多相似文章