四季花海
使用DictDiffer:from dictdiffer import diff, patch, swap, revertdictA = { 'flower': { 'jasmine': 10, 'roses': { 'red': 1, 'white': 2 } }, 'fruit': { 'apple':3 } }dictB = { 'flower': { 'jasmine': 10, 'roses': { 'red': 1, 'white': 2 } }, 'fruit': { 'apple':3, 'orange': 4 } }result = diff(dictA, dictB)# [('add', 'fruit', [('orange', 4)])]print(f'Diffrence :\n{list(result)}')patched = patch(result, dictA)# {'flower': {'jasmine': 10, 'roses': {'red': 1, 'white': 2}}, 'fruit': {'apple': 3}}print(f'Apply diffrence :\n{patched}')