码迷,mamicode.com
首页 > 编程语言 > 详细

Learn Python 009: Dictionary

时间:2017-07-15 00:00:51      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:highlight   python   dict   logs   blog   nbsp   let   emma   nts   

# 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

标签:highlight   python   dict   logs   blog   nbsp   let   emma   nts   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!