numpy 中array拷贝

# -*- coding: utf-8 -*-
import numpy as np

a = np.array([[1,2,3,4],
            [2,4,6,8,],
            [3,6,9,12]])
print(a)

# print("bbbbbbbbbbbbbb")
# b = a[0].copy()							# 不会改变a中的值
# print(b)
# b[0] = 0
# print(b)

print("cccccccccccccc")
c = a[0,:]									# 会改变a中的值
print(c)
c[0] = 0
print(c)

print(a)
import numpy as np
aaa = np.array([[1,2,3,4],
                    [5,6,7,8],
                    [9,10,11,12]])
 index = [0,2]
 ll = aaa[index]										# 用index列表的方式,是深拷贝
 # ll = aaa[:2,:]										# 冒号切片的方式是浅拷贝
 print(ll)
 ll[1][0] = 10000
 print(ll)
 print(aaa)
    ```

你可能感兴趣的:(numpy 中array拷贝)