天天看点

AttributeError: ‘list‘ object has no attribute ‘shape‘

原因:

list

对象没有属性

shape

解决方法:

numpy库中

np.array

可使用

shape

对于列表

list

,不能使用

shape

来查看列表的维度。

如果非要想查看列表维度,可以将列表转为

array

格式,然后使用

shape

即可。

# list_0为需要查看shape的list
list_shape = np.array(list_0).shape
print(list_shape)