Python 字典 pop() 方法
Python 教程
· 2019-02-03 09:14:18
描述
Python 字典 pop() 方法删除字典给定键 key 及对应的值,返回值为被删除的值。key 值必须给出。 否则,返回 default 值。
语法
pop()方法语法:
pop(key[,default])
参数
- key: 要删除的键值
- default: 如果没有 key,返回 default 值
返回值
返回被删除的值。
实例
以下实例展示了 pop() 方法的使用方法:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
site= {'name': '码农教程', 'alexa': 10000, 'url': 'www.codercto.com'}
pop_obj=site.pop('name')
print pop_obj # 输出 :码农教程
点击查看所有 Python 教程 文章: https://www.codercto.com/courses/l/8.html
We Are the Nerds
Christine Lagorio-Chafkin / Hachette Books / 2018-10-2 / USD 18.30
Reddit hails itself as "the front page of the Internet." It's the third most-visited website in the United States--and yet, millions of Americans have no idea what it is. We Are the Nerds is an eng......一起来看看 《We Are the Nerds》 这本书的介绍吧!