Python

[Python]优雅的dictionary使用

2017-11-30  本文已影响0人  Chemizi

#good

ages=dict(Dave=24,Mary=42,John=58)

print(ages.get('Dave'))

#not good

ages={'Dave':24,'Mary':42,'John':58}

print(ages['Dave'])

上一篇下一篇

猜你喜欢

热点阅读