#标注 sorted()函数默认按ascii排序 # coding=utf-8import urllibdict_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+"="+vprint(result)
[(‘Aadmin‘, ‘33FFFHtest‘), (‘test‘, ‘FFFF‘), (‘key‘, ‘values‘)]
Aadmin=33FFFHtesttest=FFFFkey=values
原文地址:https://www.cnblogs.com/SunshineKimi/p/12397668.html
时间: 2024-10-10 04:27:00