python中浅拷贝和深拷贝的区别如下:
1. copy.copy 浅拷贝 只拷贝父对象,不会拷贝对象的内部的子对象。
2. copy.deepcopy 深拷贝 拷贝对象及其子对象
In [21]: id(aa)
Out[21]: 4525363104
In [22]: id(bb)
Out[22]: 4525363104
In [23]: id(cc)
Out[23]: 4520804176
In [24]: dd = copy.deepcopy(aa)
In [25]: id(dd)
Out[25]: 4524152464
In [26]: aa.append(88)
In [27]: aa
Out[27]: [1, 2, [3, 5, 6], 88]
In [28]: id(aa)
Out[28]: 4525363104
In [29]: dd
Out[29]: [1, 2, [3, 5, 6]]
In [30]: id(dd)
Out[30]: 4524152464
In [31]: cc
Out[31]: [1, 2, [3, 5, 6]]
In [32]: bb
Out[32]: [1, 2, [3, 5, 6], 88]