DICT数据处理
作者:
9016 | 来源:发表于
2021-07-22 07:16 被阅读0次import hashlib
def sigCount_post(param, sourceType):
keyValueString = ""
keyList = list(param.keys()) #拿到KEY列表
keyList.sort()#对KEY列表排序
for i in keyList:
valueString = param.get(i)
keyValueString = '%s%s%s' % (keyValueString, i, valueString)
if sourceType == 'driver':
stringFinal = keyValueString + '083fc70e-49a1-11e2-9d96-' # 司机端secret
print(stringFinal)
else:
stringFinal = keyValueString + '47f3db98-eaa5-11e1-92bc-' # 用户端secret
signParam = Md5Change(stringFinal)
param['sig'] = signParam#在DICT里加上一行sig的KEY-VALUE
return param # post方法返回一个加了sig的字典
def Md5Change(param):
m = hashlib.md5()
m.update(param.encode('utf-8'))
sigString = (m.hexdigest())
return sigString
本文标题:DICT数据处理
本文链接:https://www.haomeiwen.com/subject/ancemltx.html
网友评论