#定义一个字典 dic = {'name':'wusan','pwd':27,'sex':'女'} #循环打印出默认的字典元素,实际为key值 for item in dic: print(item) #循环打印出字典中的key值 for item in dic.keys(): print(item) #循环打印出字典中的value值 for item in dic.values(): print(item) #循环打印出字典中的键值对 for item in dic.items(): print(item) #循环分别打印出字典中的key值和value值 for k,v in dic.items(): print(k) print(v)