shaoheshaohe 发表于 2019-4-21 21:14:48

numpy copy & deep copy

import numpy as np

# copy & deep copy

a = np.arange(4)
print(a)
b = a
c = a
d = b

# 改变a 的值
print('******************')
a = 11
print(a)
print(b)
print(b is a)
print('******************')
print(c)
print(c is a)
print('******************')
d =
print(d)
print(a)
print(d is a)
print('******************')

# deep copy
b = a.copy()
print(b)
a = 44
print(a)
print(b)
print('******************')

结果:




True


True



True






---------------------


页: [1]
查看完整版本: numpy copy & deep copy