您要使用的
dict.update方法:
d1 = {'UID': 'A12B4', 'name': 'John', 'email': 'hi@example.com'}d2 = {'UID': 'A12B4', 'other_thing': 'cats'}d1.update(d2)输出:
{'email': 'hi@example.com', 'other_thing': 'cats', 'UID': 'A12B4', 'name': 'John'}从文档中:
使用其他键/值对更新字典,覆盖现有键。不返回。



