有没有更好的方法来比较字典的值?

14 浏览
0 Comments

有没有更好的方法来比较字典的值?

我目前正在使用以下功能来比较字典的值并显示所有不匹配的值。有没有更快或更好的方法来做到这一点?

match = True
for keys in dict1:
    if dict1[keys] != dict2[keys]:
        match = False
        print(keys)
        print(dict1[keys], '->', dict2[keys])

编辑:两个字典都包含相同的键。

0