# 创建字典 d1={'jack1':'values1','jack2':'values2','jack3':'values3','jack4':'values4','jack5':'values5'} d2={'jack1':'values1','jack2':'values2','jack7':'values7','jack8':'values8','jack9':'values9'} # 获取字典中values print(d1['jack3']) #循环输出字典中的key for k in d1.keys(): print(k) #循环输出字典中的values for v in d1.values(): print(v) #循环输出字典中的key,values for k,v in d1.items(): print(k,v)
#删除字典中某个值 del d1['jack1'] print(d1) #清空整个字典 d1.clear() print(d1)