太阳不下山 发表于 2021-7-23 17:02:36

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

1、JSfunction 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%DE3、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>
文档来源:51CTO技术博客https://blog.51cto.com/u_13283759/3175985


页: [1]
查看完整版本: 【Web】Javascript、Python、Django模板配合处理URL Encode