dic1 = {'date':'2018.11.2','name':'carlber','work':"遍历",'number':3} for i in dic1: #遍历字典中的键 print(i) for key in dic1.keys(): print(key) for value in dic1.values(): #遍历字典中的值 print(value) for item in dic1.items(): #遍历字典中的元素 print(item) for i in dic1: print("该次循环得到的key为%s,得到的值为%s"%(i,dic1[i]))
标签:遍历,python,dic1,key,print,四种,字典 From: https://www.cnblogs.com/kevin-yang123/p/16937097.html