a = {"boby1":{"company":"immoc1"},
"boby2": {"company": "immoc2"}}
#shallow copy
new1 = a.copy()
new1["boby1"]["company"] = "imooc3"
pass
#deepcopy
import copy
new2 = copy.deepcopy(a)
new2["boby2"]["company"] = "imooc3"
pass
list1 = ["boby1","boby2"]
print(list1)
# fromkeys
new_dict = dict.fromkeys(list1, {"company":"imooc"})
print(new_dict)
#setdefault
value = new_dict.setdefault("boby1", 1)
print(value)
print(new_dict)
value = new_dict.setdefault("body3", "immoc3")
print(value)
print(new_dict)
#get
value = new_dict.get("boby",1)
print(value)
print(new_dict)
#update
new_dict.update(boby="immoc3")
print(new_dict)
pass
浅拷贝
深拷贝
fromkeys
setdefault
get
update