Model_Grammar
python List拷贝复制
直接赋值:
old = [1,[1,2,3],3]
new = []
for i in range(len(old)):
new.append(old[i])
new[0] = 3
new[1][0] = 3
'''
-----------------------
Before:
[1, [1, 2, 3], 3]
[1, [1, 2, 3], 3]
After:
[3, [3, 2, 3], 3]
[3, [3, 2, 3], 3]
-----------------------
'''浅拷贝:
1.copy()方法
2.使用列表生成式
3.for循环遍历
4.使用切片
深拷贝:
reshape中的-1
Last updated