首页 > 编程语言 > 详细

Learn Python 009: Dictionary

时间:2017-07-14 23:32:36      阅读:274      评论:0      收藏:0      [点我收藏+]
# create a dictionary
students = {"Alice": 24, "Bob": 26, "Clark": 23, "Dan": 28, "Emma": 31}
# add entry to a dictionary
students[‘Fred‘] = 27
# alter an entry
students[‘Alice‘] = 25
# delete entry
del students[‘Fred‘]

students2 = {
        "Alice": [‘ID01‘, 24, ‘A-‘],
        "Bob": [‘ID02‘, 26, ‘B+‘],
        "Clark": [‘ID03‘, 23, ‘B‘],
        "Dan": {‘id‘: ‘ID04‘, ‘age‘: 28, ‘grade‘: ‘A‘},
        }

 

Learn Python 009: Dictionary

原文:http://www.cnblogs.com/mxyzptlk/p/7172998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!