美文网首页Python
[Python]优雅的dictionary使用

[Python]优雅的dictionary使用

作者: Chemizi | 来源:发表于2017-11-30 19:50 被阅读0次

    #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