Python3 字典 pop() 方法
Python 3 教程
· 2019-02-06 17:27:46
描述
Python 字典 pop() 方法删除字典给定键 key 所对应的值,返回值为被删除的值。key值必须给出。 否则,返回default值。
语法
pop()方法语法:
pop(key[,default])
参数
- key: 要删除的键值
- default: 如果没有 key,返回 default 值
返回值
返回被删除的值。
实例
以下实例展示了 pop() 方法的使用方法:
>>> site= {'name': '码农教程', 'alexa': 10000, 'url': 'www.codercto.com'}
>>> pop_obj=site.pop('name')
>>> print(pop_obj)
码农教程
点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html
Alone Together
Sherry Turkle / Basic Books / 2011-1-11 / USD 28.95
Consider Facebookit’s human contact, only easier to engage with and easier to avoid. Developing technology promises closeness. Sometimes it delivers, but much of our modern life leaves us less connect......一起来看看 《Alone Together》 这本书的介绍吧!