#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'])
#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'])
本文标题:[Python]优雅的dictionary使用
本文链接:https://www.haomeiwen.com/subject/whdbbxtx.html
网友评论