python 示例_带有示例的Python字典update()方法
python 示例
字典update()方法 (Dictionary update() Method)
update() method is used to update the dictionary by inserting new items to the dictionary.
update()方法用于通过将新项目插入字典来更新字典。
Syntax:
句法:
dictionary_name.setdefault(iterable)
Parameter(s):
参数:
iterable – It represents an iterbale object or a dictionary to be inserted in the dictionary.
可迭代 –表示要在字典中插入的iterbale对象或字典。
Return value:
返回值:
It returning nothing.
它什么也没返回。
Example:
例:
# Python Dictionary update() Method with Example
# dictionary declaration
student = {"roll_no": 101,
"name": "Shivang",
"course": "B.Tech",
"perc" : 98.5
}
# printing dictionary
print("data of student dictionary...")
print(student)
# inserting an item
student.update({'city' : 'Indore'})
# printing dictionary after update()
print("data of student dictionary after update()...")
print(student)
# inserting multiple items
student.update({'city' : 'Indore', 'address' : 'Tech park'})
# printing dictionary after update()
print("data of student dictionary after update()...")
print(student)
Output
输出量
data of student dictionary...
{'roll_no': 101, 'name': 'Shivang', 'course': 'B.Tech', 'perc': 98.5}
data of student dictionary after update()...
{'roll_no': 101, 'name': 'Shivang', 'course': 'B.Tech', 'perc': 98.5, 'city': 'Indore'}
data of student dictionary after update()...
{'roll_no': 101, 'name': 'Shivang', 'course': 'B.Tech', 'perc': 98.5, 'city': 'Indore', 'address': 'Tech park'}
翻译自: https://www.includehelp.com/python/dictionary-update-method-with-example.aspx
python 示例
python 示例_带有示例的Python字典update()方法相关推荐
- python 示例_带有示例的Python字典popitem()方法
python 示例 字典popitem()方法 (Dictionary popitem() Method) popitem() method is used to remove random/last ...
- python示例_带有示例的Python功能指南
python示例 Python函数简介 (Introduction to Functions in Python) A function allows you to define a reusable ...
- python 示例_带有示例的Python File write()方法
python 示例 文件write()方法 (File write() Method) write() method is an inbuilt method in Python, it is use ...
- lock_sh 示例_带有示例的Python date __str __()方法
lock_sh 示例 Python date .__ str __()方法 (Python date.__str__() Method) date.__str__() method is used t ...
- python 示例_带有示例的Python文件关闭属性
python 示例 文件关闭属性 (File closed Property) closed Property is an inbuilt property of File object (IO ob ...
- python 示例_带有示例的Python date timetuple()方法
python 示例 Python date.timetuple()方法 (Python date.timetuple() Method) date.timetuple() method is used ...
- python 示例_带有示例的Python date isocalendar()方法
python 示例 Python date.isocalendar()方法 (Python date.isocalendar() Method) date.isocalendar() method i ...
- python 示例_带有示例的Python File close()方法
python 示例 文件close()方法 (File close() Method) close() method is an inbuilt method in Python, it is use ...
- python 示例_带有示例的Python列表remove()方法
python 示例 列出remove()方法 (List remove() Method) remove() method is used to remove the first occurrence ...
最新文章
- 记录一下CUDNN配置
- Android学习——自定义控件(二)
- android没有捂脸表情,Emoji神器 | 如果你也喜欢[捂脸]表情
- mysql 普通sql流程控制,【mysql的编程专题①】流程控制与其他语法
- Angular list列表绑定的一个例子
- vuex的命名空间有哪些_Vuex在vue路由器中访问命名空间模块的getter
- 简述mysql实现递归查询的方法
- 如何使用Python 画笔
- 中国芯的ISSCC/JSSC之路
- linux查看设备网卡型号,linux查看网卡型号
- 学习总结——小程序中输入框和键盘的那些事
- 如何在PDF文件中快速查找关键字,这个方法后悔没早点知道
- pandas 取每天某个时刻的数据
- 最全面计算机英语单词列表(四)
- SQLI DUMB SERIES-7
- stm32芯片休眠模式_STM32睡眠模式低功耗(停止模式)
- 苹果首款无线充电宝曝光,我们要怎么去选择
- 浑身尖刺的服务可用性守护者——hystrix熔断器实践记录
- android开发相册代码,Android开发之简单的电子相册实现
- 思科、华为交换机链路聚合(LACP)配置实例
热门文章
- html字符实体标签语法,HTML字符实体与文本格式化标签
- maven 打包指定依赖包_[Maven]-Maven基础-01-基础概念
- AngularJS(九):路由
- 前端图片canvas,file,blob,DataURL等格式转换
- 阅读react-redux源码(五) - connectAdvanced中store改变的事件转发、ref的处理和pure模式的处理
- cf1208G Polygons 欧拉函数
- Java实现并发线程中线程范围内共享数据
- 【BZOJ4262】Sum 单调栈+线段树
- 程序猿果真有前端后端client吗
- Spark Streaming整合logstash + Kafka wordCount