返回顶部

收藏

Dictionary get value

更多
d = {}

#Not so with get:

print d.get('name')

#You may supply your own 'default' value, which is then used instead of None:

print d.get('name', 'N/A')

# If the key is there, get works like ordinary dictionary lookup:

d['name'] = 'Eric'
print d.get('name')

标签:Python,Dictionary

收藏

0人收藏

支持

0

反对

0

发表评论