有人能为我解释一下吗?(Python 3.3.2,numpy 1.7.1):
>>> a = np.array([[1,2],[3,4]])
>>> a # just a peek
array([[1, 2],
[3, 4]])
>>> a.resize(3,2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot resize an array references or is referenced
by another array in this way. Use the resize function
>>> a = np.array([[1,2],[3,4]])
>>> a.resize(3,2)
>>> a
array([[1, 2],
[3, 4],
[0, 0]])
>>> a = np.array([[1,2],[3,4]])
>>> print(a) # look properly this time
[[1 2]
[3 4]]
>>> a.resize(3,2)
>>> a
array([[1, 2],
[3, 4],
[0, 0]])
为什么看一眼数组会创建一个对它的引用?(或者至少,在我查看之后为什么这个引用仍然存在?)此外,是只有我觉得那个异常需要重写一下吗?