'''
1.b = a
b 发生变化 a 也会发生变化
2.浅复制
c = a.view()
c.shape 发生变化,a.shape 不会发生变化
c 和 a 共用元素值,id 指向不同
c[1,0] = 1234 , a 的值也会发生变化
3.深复制
d = a.copy()
d[0,0] = 999
d 发生改变,a 不会发生改变
'''
import numpy as np
a = np.arange(1,8)
# array([1, 2, 3, 4, 5, 6, 7])
b = a
b[2] = 999
b
# array([ 1, 2, 999, 4, 5, 6, 7])
a
# array([ 1, 2, 999, 4, 5, 6, 7])
a = np.arange(1,9)
c = a.view()
c.shape = 4,2
'''
array([[1, 2],
[3, 4],
[5, 6],
[7, 8]])
'''
a
# array([1, 2, 3, 4, 5, 6, 7, 8])
d = a.copy()
d[3] = 888
d
# array([ 1, 2, 3, 888, 5, 6, 7, 8])
a
# array([1, 2, 3, 4, 5, 6, 7, 8])
2020-04-10