dict1 = {'4000' : (100.05, 200.08, 300.96, True), '1234': (39.45,1200.09,208.34, True)}
dict2 = {'4000' : (100.05, 200.08, 400.96, True), '1234': (39.45,1205.09,208.34, True)}
我想要比较的是相同索引下的值(100.05 == 100.05?200.08 == 200.08?300.96 == 400.96 ?,以此类推)。然后我要打印出差异(如果存在):
'Difference: Third Number, +100'
非常感谢。
答案 0 :(得分:0)
您尚未确切指定所需的输出,但是,假设我们的值的长度相同,则可以运行以下命令:
for k in dict1.keys():
for i in range(len(dict1[k])):
if dict1[k][i] != dict2[k][i]:
print(k, i, dict1[k][i], dict2[k][i])
答案 1 :(得分:0)
for key in list(dict1):
val1 = dict1[key]
val2 = dict2[key]
for i in range(len(val1)):
print(val1[i] == val2[i])