dict={"a":"apple","b":"banana","o":"orange"} 

print "##########dict######################"
for i in dict:
print "dict[%s]=" % i,dict[i] print "###########items#####################"
for (k,v) in dict.items():
print "dict[%s]=" % k,v print "###########iteritems#################"
for k,v in dict.iteritems():
print "dict[%s]=" % k,v print "###########iterkeys,itervalues#######"
for k,v in zip(dict.iterkeys(),dict.itervalues()):
print "dict[%s]=" % k,v

python 遍历字典的更多相关文章

  1. Python遍历字典

    1.遍历key值 1 >>> d = {'Python':'astonishing', 'C++':'complicated', 'Java':'versatile'} 2 > ...

  2. python遍历字典元素

    a={'a':{'b':{'c':{'d':'e'}},'f':'g'},'h':'i'} def show(myMap): for str in myMap.keys(): secondDict=m ...

  3. python 遍历字典中的键和值

    #遍历字典中的所有键和值 zd1={"姓名":"张三","年龄":20,"性别":"女"} zd2= ...

  4. Python遍历字典dict的几种方法

    #!/usr/bin/python dict={"a":"apple","b":"banana","o&quo ...

  5. Python简单遍历字典及删除元素的方法

    Python简单遍历字典及删除元素的方法 这篇文章主要介绍了Python简单遍历字典及删除元素的方法,结合实例形式分析了Python遍历字典删除元素的操作方法与相关注意事项,需要的朋友可以参考下 具体 ...

  6. python 取出字典的键或者值/如何删除一个字典的键值对/如何遍历字典

    先定义一个字典并直接进行初始化赋值 my_dict = dict(name="lowman", age=45, money=998, hourse=None) 1.取出该字典所有的 ...

  7. python中字典的循环遍历的两种方式

    开发中经常会用到对于字典.列表等数据的循环遍历,但是python中对于字典的遍历对于很多初学者来讲非常陌生,今天就来讲一下python中字典的循环遍历的两种方式. 注意: python2和python ...

  8. Python中使用item()方法遍历字典的例子

    Python中使用item()方法遍历字典的例子 这篇文章主要介绍了Python中使用item()方法遍历字典的例子,for...in这种是Python中最常用的遍历字典的方法了,需要的朋友可以参考下 ...

  9. python中字典dic详解-创建,遍历和排序

    原文地址:http://www.bugingcode.com/blog/python_dic_create_sort.html 在python的编程中,字典dic是最典型的数据结构,看看如下对字典的操 ...

随机推荐

  1. 如何编译libcurl

    1. Android •1.1配置 •1.2 Make •1.3的参数配置 2.iOS 3.windows 4.关于头文件 注释 本文档介绍了如何为Android,iOS和Windows编译libcu ...

  2. 网格GridLayout建立

    import java.awt.*;public class GridFlowout extends Frame { public GridFlowout (String str){ {setTitl ...

  3. Android(java)学习笔记140:SpannableString类的使用

    我们之前说过了我们想实现在TextView组件之中,可以显示URL.Email等特殊信息,这些信息点击可以实现跳转,真正意义上的超链接 要实现上面的需求就要SpannableString这个类. 因为 ...

  4. bit,byte,char,string区别与基本类型认识

    bit.byte.位.字节.汉字的关系 1 bit     = 1  二进制数据        1 byte  = 8  bit        1 字母 = 1  byte = 8 bit       ...

  5. E: Sub-process /usr/bin/dpkg returned an error code (1)

    E: Sub-process /usr/bin/dpkg returned an error code (1) 错误描述 dpkg: error processing archive /var/cac ...

  6. Java并发——同步容器与并发容器

    同步容器类 早期版本的JDK提供的同步容器类为Vector和Hashtable,JDK1.2 提供了Collections.synchronizedXxx等工程方法,将普通的容器继续包装.对每个共有方 ...

  7. (转)使用OpenVPN的一些注意事项

    原文地址:http://www.365mini.com/page/16.htm 本文介绍的只是OpenVPN连接或使用过程中的一些注意事项,如果你尚未下载安装OpenVPN,你可以点击查看OpenVP ...

  8. JS实现各种页面的刷新

    JS实现各种页面的刷新功能 1.刷新当前页面 opener.location.replace(opener.location.href); 或者window.opener.window.locatio ...

  9. IOC主要接口

  10. WordLight: highlights all occurrences of a selected text for VS2008

    https://visualstudiogallery.msdn.microsoft.com/ad686131-47d4-4c13-ada2-5b1a9019fb6f About This is a ...