info ={
"name":"tengxun",
"name1":"ali",
"name2":"baidu"
}
b= {
'name':'liufeng',
1:3,
2:5
}
# info.update(b)#两个字典和成一个字典
# print(info)
# print(info.items())#转换成列表
# c = info.fromkeys([6,7,8],"test")#创建一个新的字典
# print(c)
# b = info.fromkeys([6,7,8],[1,{"name":"test"},444])#创建一个新的字典
# print(b)
# b[7][1]['name']='jack chen'#类似于浅copy
# print(b)
# print(info)
# print(info["name"])
# info["name1"]="武藤兰"
# info["name4"]="苍井空"
# print(info)
# # del info["name1"]
# # print(info)
# info.pop("name1")
# print(info)
#select
# print(info["name1"])
# print(info.get("name1"))
# print("name1" in info)
#多级字典嵌套及操作
# info2 ={
# "sichuan":{"chengdu":{"wuhouqu":["chunxilu" ,"chifan"] },"mianyang":{"hongguangcun":"xiaoer"}},
# "name1":
# {
# "ali":["BIG BIG COMpany"]
# },
# "name2":"baidu"
# }
# # print(info2)
# info2.setdefault("taiwan",{"www.baiduc.com":[1,2]})#先去字典取台湾值,取不到创建个新的
# # print(info2)
# #update
# info2["sichuan"]["chengdu"]["wuhouqu"][1]="可以去吃饭了"
# # print(info2["sichuan"]["chengdu"]["wuhouqu"][0])
# # print(info2["name1"]["ali"][0])
# print(info2)
# print(info2.values())
# print(info2.keys())
#循环
for i in info:
print(i)#取key值
print(i,info[i])#取key值和value值
for k,v in info.items():
print(k,v)
#上面的循环比下面的循环高效很多。item是转换成列表去循环