实际遇到的问题逻辑很繁杂,就不全写了.最后是通过对比两个字典差异来解决的.找出两个字典的差异,可参考以下代码. dict1 = {'a':1,'b':2,'c':3,'d':4} dict2 = {'a':1,'b':2,'c':5,'e':6} differ = set(dict1.items()) ^ set(dict2.items()) print(differ) #所有差异 #输出:{('c', 3), ('e', 6), ('c', 5), ('d', 4)} diff = dict1