行 和 列
的概念适用于2D数组。但是,该数组
numpy.array([1,2,3,4])是一维数组,因此只有一个维,因此
shape正确地返回一个单值可迭代的数组。
对于同一阵列的2D版本,请考虑以下内容:
>>> a = numpy.array([[1,2,3,4]]) # notice the extra square braces>>> a.shape(1, 4)

行 和 列
的概念适用于2D数组。但是,该数组
numpy.array([1,2,3,4])是一维数组,因此只有一个维,因此
shape正确地返回一个单值可迭代的数组。
对于同一阵列的2D版本,请考虑以下内容:
>>> a = numpy.array([[1,2,3,4]]) # notice the extra square braces>>> a.shape(1, 4)