|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
data1 = {}
data1['i'] = '字符串'
data1['from'] = ' AUTO'
data1['to'] = ' AUTO'
data1['smartresult'] = 'dict'
data1['client'] = 'fanyideskweb'
data1['salt'] = '15964214581609'
data1['sign'] = ' 454457e207473b5f63ee6d374d56bd6d'
data1['ts'] = '1596421458160'
data1['bv'] = 'bc250de095a39eeec212da07435b6924'
data1['doctype'] = ' json'
data1['version'] = '2.1'
data1['keyfrom'] = 'fanyi.web'
data1['action'] = 'FY_BY_REALTlME'
data2 = {"i": '字符串', "from": "AUTO", "to": "AUTO", "smartresult": "dict", "client": "fanyideskweb", "salt": "15964214581609", \
"sign": "454457e207473b5f63ee6d374d56bd6d", "ts": "1596421458160", "bv": "bc250de095a39eeec212da07435b6924", \
"doctype": "json", "version": "2.1", "keyfrom": "fanyi.web", "action": "FY_BY_REALTlME"}
if data1 == data2:
print('相同')
else:
print('不相同')
请问下大佬们为什么输出结果是不一样,这两个字典哪不同了?求解惑
改成这样即可,你的 data1 里面 data1['from']、data1['to']、data1['sign']、data1['doctype'] 都多了个空格了
data1 = {}
data1['i'] = '字符串'
data1['from'] = 'AUTO'
data1['to'] = 'AUTO'
data1['smartresult'] = 'dict'
data1['client'] = 'fanyideskweb'
data1['salt'] = '15964214581609'
data1['sign'] = '454457e207473b5f63ee6d374d56bd6d'
data1['ts'] = '1596421458160'
data1['bv'] = 'bc250de095a39eeec212da07435b6924'
data1['doctype'] = 'json'
data1['version'] = '2.1'
data1['keyfrom'] = 'fanyi.web'
data1['action'] = 'FY_BY_REALTlME'
data2 = {"i": '字符串', "from": "AUTO", "to": "AUTO", "smartresult": "dict", "client": "fanyideskweb", "salt": "15964214581609", \
"sign": "454457e207473b5f63ee6d374d56bd6d", "ts": "1596421458160", "bv": "bc250de095a39eeec212da07435b6924", \
"doctype": "json", "version": "2.1", "keyfrom": "fanyi.web", "action": "FY_BY_REALTlME"}
if data1 == data2:
print('相同')
else:
print('不相同')
|
|