import copy
dict1 = {}
dict2 = {}
dict1["name"] = "aaa"
dict1["age"] = 20
tmp = copy.deepcopy(dict1)
dict2 = tmp
dict2.pop("name")
print(dict1)
print(dict2)
深拷贝后改变新的字典,原字典的数值不受影响
import copy
dict1 = {}
dict2 = {}
dict1["name"] = "aaa"
dict1["age"] = 20
tmp = copy.deepcopy(dict1)
dict2 = tmp
dict2.pop("name")
print(dict1)
print(dict2)
深拷贝后改变新的字典,原字典的数值不受影响