d1= {'a':{'b':{'cs':10},'c':88,'d':[{'cs':[20]},{'cc':22}]}}
d2= {'a':{'b':{'cs':30},'c':88,'d':[{'cs':[20,33]},{'cc':333}]},'newa':{'q':{'cs':50}}}
def dictDiff(old, new):
for k in old:
if k in new:
if isinstance(old,list):
new.remove(k)
elif isinstance(old[k],(list,dict)):
dictDiff(old[k],new[k])
elif old[k] == new[k]:
del new[k]
dictDiff(d1,d2)
print(d2)
不过这个还是有点问题的,子数组还是不能比对,仅供参考。