首页 > 编程语言 > 详细

python中字典的方法update

时间:2019-04-26 22:35:02      阅读:114      评论:0      收藏:0      [点我收藏+]

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

>>> 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}

python中字典的方法update

原文:https://www.cnblogs.com/w-j-c/p/10776618.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!