码迷,mamicode.com
首页 > 其他好文 > 详细

字典操作

时间:2017-05-02 11:51:25      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:ict   user   使用   wan   use   dict   特性   运行   数据类型   

 字典一种key - value 的数据类型,使用就像我们上学用的字典,通过笔划、字母来查对应页的详细内容。

student = {
‘user‘:‘tangbo‘
‘user1‘:‘renchuan‘
‘user2‘:‘wangsi‘

}
字典的特性:
dict是无序的
key必须是唯一的,so 天生去重.

添加:
student = {
‘user‘: ‘tangbo‘,
‘user1‘: ‘renchuan‘,
‘user2‘:‘wangsi‘,
}
student[‘user03‘] = ‘bowen‘
print(student)
运行结果:{‘user03‘: ‘bowen‘, ‘user2‘: ‘wangsi‘, ‘user‘: ‘tangbo‘, ‘user1‘: ‘renchuan‘}

字典操作

标签:ict   user   使用   wan   use   dict   特性   运行   数据类型   

原文地址:http://www.cnblogs.com/tangbo/p/6794942.html

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