Python 字典(Dictionary) update()方法

发布时间:2020-08-04 00:36:15 作者:ck_god
来源:网络 阅读:2167

Python 字典(Dictionary) update()方法
描述:
Python 字典(Dictionary) update() 函数把字典dict2的键/值对更新到dict里。

语法:
update()方法语法:

dict.update(dict2)
参数:
dict2 -- 添加到指定字典dict里的字典。
返回值:
该方法没有任何返回值。

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

#!/usr/bin/python

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

dict.update(dict2)
print "Value : %s" %  dict
以上实例输出结果为:

Value : {'Age': 7, 'Name': 'Zara', 'Sex': 'female'}
```Python 字典(Dictionary) update()方法
描述
Python 字典(Dictionary) update() 函数把字典dict2的键/值对更新到dict里。

语法
update()方法语法:

dict.update(dict2)
参数
dict2 -- 添加到指定字典dict里的字典。
返回值
该方法没有任何返回值。

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

#!/usr/bin/python

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

dict.update(dict2)
print "Value : %s" %  dict
以上实例输出结果为:

Value : {'Age': 7, 'Name': 'Zara', 'Sex': 'female'}
推荐阅读:
  1. python并发爬虫实用工具tomorrow实用解析
  2. python异步编程 使用yield from过程解析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python 字典 dat

上一篇:cisco设备IOS上传、备份、设置启动IOS

下一篇:解决windows server 有的机器是时间不能同步问题

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》