Part of the Source: http://blog.sina.com.cn/s/blog_5c6760940100bmg5.html
① Direct Assignment----result is a reference to a different name
The modification of the new dictionary has a full effect on the original dictionary, just a reference to the relationship
>>> C = {'a': 1,'b': 2}>>> d =C>>> d['e']=3>>>d{'a': 1,'b': 2,'e': 3}>>>c{'a': 1,'b': 2,'e': 3}>>> f =dict ()>>> f =D>>> f["k"]=4>>>f{'a': 1,'k': 4,'b': 2,'e': 3}>>>c{'a': 1,'k': 4,'b': 2,'e': 3}
② uses the copy () function---shallow copy.
If a dictionary has a reference type, such as list, replication copies its references only and does not copy its values:
>>> d = {'names': ['Bob','Sam']}>>> y =d.copy ()>>> y['names'][0] ='Jack'>>>y{'names': ['Jack','Sam']}>>>d{'names': ['Jack','Sam']}
③ Deep Copy Deepcopy
>>> fromCopyImportdeepcopy>>> d = {'names': ['Bob','Sam']}>>> y =Deepcopy (d)>>> y['names'][0] ='Jack'>>>d{'names': ['Bob','Sam']}>>>y{'names': ['Jack','Sam']}
Copy problem with "Python" dict