用另一个字典或键值对更新当前字典,已存在的键会被覆盖。
other
None
d = {"a": 1, "b": 2} d.update({"b": 20, "c": 3}) d.update(d=4) print(d)
{'a': 1, 'b': 20, 'c': 3, 'd': 4}