python 的Dict

mydict = {'code':'00001', 'name':'wayne', 'chinese':90, 'english':100}

mydict['PE'] = 'A'
mydict['math'] = 100

for (key, value) in mydict.items():
        print key,":",  value

print "--------------------------------------------"

for key in mydict:
        print key,":", mydict[key]

print "-------------------------------------------"

for key,value in mydict.iteritems():

        print key, ":", value


print "-------------------------------------------"

for key in mydict.iterkeys():
        print key, ":", mydict[key]

print '-------------------------------------------'

for key, value in zip(mydict.iterkeys(), mydict.itervalues()):
         print key, ":", value
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章