jQuery火箭图标返回顶部代码

Python3 字典 update() 方法

 Python3 字典


描述

Python 字典 update() 函数把字典dict2的键/值对更新到dict里。

语法

update()方法语法:

dict.update(dict2)

参数

  • dict2 -- 添加到指定字典dict里的字典。

返回值

该方法没有任何返回值。

实例

以下实例展示了 update()函数的使用方法:

#!/usr/bin/python3

dict = {'Name': 'Runoob', 'Age': 7}
dict2 = {'Sex': 'female' }

dict.update(dict2)
print ("更新字典 dict : ", dict)

以上实例输出结果为:

更新字典 dict :  {'Sex': 'female', 'Age': 7, 'Name': 'Runoob'}

 Python3 字典

 声明:原文来自菜鸟教程http://www.runoob.com/python3/

 

posted @ 2018-03-22 01:17  墨颜丶  阅读(2644)  评论(0编辑  收藏  举报