如下,update() 用于把字典 dict2 的键/值对更新到 dict1 里,相当于追加字典
In [13]: dict1 = { "a":1, "b": 2}In [14]: dict2 = { "c":3, "d": 4}In [15]: dict1.update(dict2)In [16]: dict1Out[16]: { 'a': 1, 'b': 2, 'c': 3, 'd': 4}
本文共 260 字,大约阅读时间需要 1 分钟。
如下,update() 用于把字典 dict2 的键/值对更新到 dict1 里,相当于追加字典
In [13]: dict1 = { "a":1, "b": 2}In [14]: dict2 = { "c":3, "d": 4}In [15]: dict1.update(dict2)In [16]: dict1Out[16]: { 'a': 1, 'b': 2, 'c': 3, 'd': 4}
转载于:https://www.cnblogs.com/pzk7788/p/10247839.html