>>> dict1={'k1':'v1','k2':'v2'}
>>> dict1.get('k1','k2') #结果只有一个
'v1'
>>> dict1.get('k11','k2') #忽略不存在的键,结果为第二个键(不管存在与否)
'k2'
>>> dict1.get('k11','k256') #'k256'
'k256'
>>>
python字典get()方法
最新推荐文章于 2023-01-21 00:13:45 发布
>>> dict1={'k1':'v1','k2':'v2'}
>>> dict1.get('k1','k2') #结果只有一个
'v1'
>>> dict1.get('k11','k2') #忽略不存在的键,结果为第二个键(不管存在与否)
'k2'
>>> dict1.get('k11','k256') #'k256'
'k256'
>>>