python中字典的方法update

使用场景:涉及两个字典的合并时
实例:
1.

>>> D1 = {'one':1, 'two':2}
>>> D2 = {'three':3}
>>> D1.update(D2)
>>> D1
{'one': 1, 'two': 2, 'three': 3}
>>> D1 = {'one':1, 'two':2}
>>> D1.update(three=3)
>>> D1
{'one': 1, 'two': 2, 'three': 3}
posted @ 2019-04-26 21:04  樱花色的梦  阅读(287)  评论(0编辑  收藏  举报