字典和列表生成式
There are syntax constructions to ease the creation of a Dictionary or List based on existing iterable.
可以简化基于可迭代对象创建列表或字典的语法结构。
列表生成式List Comprehension
语法:[条件表达式 for i in iterable]

迭代字典的方法
方法一:最佳使用方式
1 for key in info: 2 print(key,info[key]) 3 4 stu1102 aaaaa 5 stu003 b 6 stu004 c 7 3 4 8 1 None 9 new setdefault value 10 111 222
方法二: #会先把dict转成list,数据里大时莫用
1 for k,v in info.items(): 2 print(k,v) 3 4 stu1102 aaaaa 5 stu003 b 6 stu004 c 7 3 4 8 1 None 9 new setdefault value 10 111 222
字典的属性介绍: http://www.cnblogs.com/zoe233/articles/7017393.html
本站仅用于个人学习的笔记和记录,有时候是阅读别人的文章的时候做着笔记整理,有些是在实际工作中遇到的问题以及解决小问题的记录。
当前仅用于作为一个萌新程序媛的查漏补缺地检索地。

浙公网安备 33010602011771号