python 中字典的遍历
2015-04-17 23:41
155 查看
当遍历字典中的键值对时,可以用iteritems()进行遍历
如:
a = {'1':'hello','2':'world','3':'good'}
for k,v in a.iteritems():
print k,v;
结果:
1 hello
2 world
3 good
如:
a = {'1':'hello','2':'world','3':'good'}
for k,v in a.iteritems():
print k,v;
结果:
1 hello
2 world
3 good
相关文章推荐
- Python字典的一些遍历
- Python中如何遍历字典
- Python自学之路第八步——遍历字典&嵌套
- 遍历python字典几种方法
- python 字典和列表的遍历
- 遍历python字典几种方法总结(推荐)
- Python中字典创建、遍历、添加等实用操作技巧合集
- Python开发【笔记】:如何在字典遍历中删除key值?
- 006_004 Python 链式遍历字典
- python字典英雄技能,键值对特点,删除,遍历取键值
- python两种遍历字典(dict)的方法比较
- Python中字典遍历的方法以及性能
- python 字典(dict)遍历四种方法的性能
- Python 遍历字典
- python有序遍历dict(字典)
- python 循环遍历字典元素的简单方法
- Python -- 遍历字典时删除元素报异常
- python中最常见数据结构的遍历:字符串、列表、元祖、字典
- 遍历python字典的几种方法
- python 中 五种字典(dict)的遍历方法,实验法比较性能。