码迷,mamicode.com
首页 > 编程语言 > 详细

python遍历 truple list dictionary的几种方法

时间:2015-04-09 17:22:07      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

def TestDic1():
    dict2 ={'aa':222,11:222}
    for val in dict2:
        print val
def TestDic2():
    dict2 ={'aa':222,11:222}
    for (key,val) in dict2.items():
        print key,":",val      
def TestList1():
    list=[1,2,3,4,5,3,2,'ada','fs3']
    for i in range(len(list)):
        print list[i]
def  TestDic3():
    dict2 ={'aa':222,11:222}
    print "###########iteritems#################"
    for k,v in dict2.iteritems():
        print "dict[%s]=" % k,v
def  TestDic4():
    dict2 ={'aa':222,11:222}
    print "###########iterkeys,itervalues#######"
    for k,v in zip(dict2.iterkeys(),dict2.itervalues()):
        print "dict[%s]=" % k,v        
def TestList2():
    list=[1,2,3,4,5,3,2,'ada','fs3']
    for i in list:
        print i

python遍历 truple list dictionary的几种方法

标签:

原文地址:http://blog.csdn.net/yue7603835/article/details/44962587

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