从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, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6}
>>> d.update(g=7) # no positional argument
>>> d
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句