【发布时间】:2020-04-18 21:49:34
【问题描述】:
我正在自学 Python,遇到了一个我难以规避的问题。我正在尝试使用 Numpy 库中的 .shape 函数,但无法绕过此消息。源码如下:
import numpy as np
a = [1,2,3,4,5,6,7,8,9]
a.shape
收到的错误是:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-55-091b86d34e0e> in <module>
4 [17, 22, 27])
5 a = [1,2,3,4,5,6,7,8,9]
----> 6 a.shape
AttributeError: 'list' object has no attribute 'shape'
【问题讨论】:
-
与列表一起使用
len(a)
标签: python arrays list numpy shapes