>>> a.items() dict_items([('a', 1), ('b', 2)]) >>> for key in a.keys(): print('key={}'.format(key)) key=a key=b >>> for value in a.values(): print('values={}'.format(value)) values=1 values=2 >>> for key,value in a.items(): print('{a}:{b}'.format(a=key,b=value)) a:1 b:2
字典的遍历