有人可以解释一下:
>>> import numpy as np
>>> a = np.arange(1,11)
>>> a.shape
(10,)
>>> a = a.reshape(1,10)
>>> a.shape
(1, 10)
>>> a[0]
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
>>> a[0].shape
(10,)
>>> a[0] = []
>>> a
ValueError: cannot copy sequence with size 0 to array axis with dimension 10
>>> a
array([[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]])
为什么我收到此错误?
为什么我在下面的行中得到错误而不是立即? 在完成任务后,我写的并不重要: 即。
>>> a[0] = []
>>> b = 4
ValueError: cannot copy sequence with size 0 to array axis with dimension 10
我正在使用
>>> print sys.version
2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
>>> np.version.version
'1.8.0rc1'