#update:合并两个字典,如果有交叉就覆盖更新,没有交叉的就创建
info={
'stu1101':'Liu Guannan',
'stu1102':'Wang Ruipu',
'stu1103':'Sun Yanan'
}
b={'stu1101':'Liu Guannan',
1:3,
2:5
}
info.update(b)
print(info)
#info.items()将字典变成列表,key是第一个元组的值,后边是value
print(info.items())
#fromkeys通过一个列表生成默认dict,有个没办法解释的坑,少用吧这个
c=dict.fromkeys([7,8,9],'testd')
print(c)
c=dict.fromkeys([7,8,9],['t','g','t'])
print(c)
c[7][1]='光光'
print(c)