遍历 1. 遍历字典(只能遍历key值) dic = { "1":21,"2":64,"3":98} #遍历字典只是遍历key值 for c in dic: print(c, end = ",") 结果: 1,2,3, 2. 遍历输出完整的字典内容 dic = { "1":21,"2":64,"3":98} #遍历输出完整的key-value for c in dic: print(c,':',dic[c]) 结果: 1 : 21 2 : 64 3 : 98 3. 输出字典内容的另一种方法