直接赋值:对象引用。
浅拷贝:拷贝父对象,不拷子对象
深拷贝: 使用copy 模块 deepcopy 方法,拷贝父、子对象
实例:
import copy
a1 = [11, 22, 33, 44,55, ['China', 'Russia','America']]
a2 = a1
a3 = copy.copy(a1)
a4 = copy.deepcopy(a1)
a1.append('haha')
a1[5].remove('America')
print( 'a1 = ', a1 )
print( 'a2= ', a2 )
print( 'a3 = ', a3 )
print( 'a4 = ', a4 )
```python
#以上实例输出结果
a1=[11, 22, 33, 44, 55, ['China', 'Russia'], 'haha']
a2=[11, 22, 33, 44, 55, ['China', 'Russia'], 'haha']
a3=[11, 22, 33, 44, 55, ['China', 'Russia'], 'haha']
a4=[11, 22, 33, 44,55, ['China', 'Russia','America']]