标签:items print for ascii min 函数 eve 简单 get
#标注 sorted()函数默认按ascii排序
# coding=utf-8
import urllib
dict_param={"test":"FFFF","Aadmin":"33FFFHtest","key":"values"}
target=sorted(dict_param.items(),key=lambda x:x[1],reverse=False)#字典按照value ascii排序,lambda x :x[0]按照键key ascii排序 ,数字大写小写顺序
print(target)
res= urllib.parse.urlencode(target)
print(res)
或者自己重写个拼接方法很简单:
result=""
for k,v in dict(target).items():
result +=k+"="+v
print(result)
[(‘Aadmin‘, ‘33FFFHtest‘), (‘test‘, ‘FFFF‘), (‘key‘, ‘values‘)]
Aadmin=33FFFHtesttest=FFFFkey=values
python urllib.parse.urlencode()和字典自定义ascii排序
标签:items print for ascii min 函数 eve 简单 get
原文地址:https://www.cnblogs.com/SunshineKimi/p/12397668.html