Python 字典(Dictionary) get()方法
来源:互联网 发布:对网络ip剧改编的看法 编辑:程序博客网 时间:2024/05/24 06:58
原文地址:http://www.runoob.com/python/att-dictionary-get.html
Python 字典(Dictionary) get()方法
描述
Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值。
语法
get()方法语法:
dict.get(key, default=None)
参数
- key -- 字典中要查找的键。
- default -- 如果指定键的值不存在时,返回该默认值值。
返回值
返回指定键的值,如果值不在字典中返回默认值None。
实例
以下实例展示了 get()函数的使用方法:
#!/usr/bin/pythondict = {'Name': 'Zara', 'Age': 27}print "Value : %s" % dict.get('Age')print "Value : %s" % dict.get('Sex', "Never")
以上实例输出结果为:
Value : 27Value : Never
阅读全文
0 0
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) get()方法
- Python 字典(Dictionary) setdefault()方法
- Python 字典(Dictionary) has_key()方法
- Python 字典(Dictionary) items()方法
- Python 字典(Dictionary) setdefault()方法
- python 字典 get()方法
- python 字典 get方法
- python-字典get方法
- 1006- Python 字典(Dictionary) items()方法
- Python 字典(Dictionary) get()以及operator.itemgetter函数
- python 字典的get方法
- python 字典的get方法
- Python 字典的get()方法
- Python dictionary 字典
- python Dictionary字典使用
- C++之用std::nothrow分配内存失败不抛异常
- Python 字典(Dictionary)
- python与C, C++,C#一个计算精度的区别
- java 的序列化和反序列化
- android 之mvp架构,直接上代码
- Python 字典(Dictionary) get()方法
- ICBC银行管理系统实战(1)
- Android内存溢出与优化(四)——防止Handler导致的内存泄露
- mysql高级语法
- 文章标题
- 【异步请求相关知识点】XMLHTTP.readyState的五种状态
- 原子变量 和cas 原理
- 数据表自增ID,在删除全部行后插入新行ID如何再从1开始
- Kotlin官方参考整理——02.基础