AttributeError: 'list' object has no attribute 'shape'
时间: 2023-09-21 07:11:24 浏览: 65
This error indicates that you are trying to access the "shape" attribute of a list object. However, the "shape" attribute is not a standard property of a list in Python. It is only available for NumPy arrays.
If you are working with a NumPy array, make sure that you are using the correct syntax to access its shape attribute:
```python
import numpy as np
# create a 2D array
arr = np.array([[1, 2], [3, 4]])
print(arr.shape) # output: (2, 2)
```
If you are not working with a NumPy array, you may need to use a different method to get the size or dimensions of your data structure. For example, you can use the `len()` function to get the length of a list:
```python
my_list = [1, 2, 3, 4, 5]
print(len(my_list)) # output: 5
```
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![py](https://img-home.csdnimg.cn/images/20250102104920.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)