Python3 字典 update() 方法

Python 3 教程 · 2019-02-06 16:57:33

描述

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

语法

update() 方法语法:

dict.update(dict2)

参数

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

返回值

该方法没有任何返回值。

实例

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

实例(Python 2.0+)

#!/usr/bin/python3 dict = {'Name': 'Codercto', 'Age': 7} dict2 = {'Sex': 'female' } dict.update(dict2) print ("更新字典 dict : ", dict)

以上实例输出结果为:

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

点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html

查看所有标签

Ajax for Web Application Developers

Ajax for Web Application Developers

Kris Hadlock / Sams / 2006-10-30 / GBP 32.99

Book Description Reusable components and patterns for Ajax-driven applications Ajax is one of the latest and greatest ways to improve users’ online experience and create new and innovative web f......一起来看看 《Ajax for Web Application Developers》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具