首页 > 其他 > 详细

字典操作

时间:2017-05-02 11:45:43      阅读:201      评论:0      收藏:0      [点我收藏+]

 字典一种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‘}

字典操作

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

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