Python字典的get()方法
dict.get(key)
方法返回字典中键 key
的值;若 key
不存在,默认返回 None
格式及参数
1 | dict.get(key,default) |
dict
: 字典
key
: 字典中的键
default
: key不存在时要返回的值,默认None
如果键
key
存在则返回key
的值,否则返回default
更多操作方法见:https://www.gaoyuanqi.cn/python-dict/#more
实例(3.8.8)
1 | dict = { |