来自dict.update()
文档字符串:
Docstring:
D.update([E,]**F) -> None. Update D from dict/iterable E and F.
[E,]**F
是什么意思?
update
可以接受现有字典(或键/值对的可迭代)作为其可选的位置参数,以及其他显式键/值对作为关键字参数。
例如:
>>> d = {'a': 1}
>>> e = {'b': 2}
>>> d.update(e,c=3) # dict positional argument
>>> d
{'a': 1,'b': 2,'c': 3}
>>> d.update([('d',4),('e',5)],f=6) # iterable positional argument
>>> d
{'a': 1,'c': 3,'d': 4,'e': 5,'f': 6}
>>> d.update(g=7) # no positional argument
>>> d
{'a': 1,'f': 6,'g': 7}