IndexError: index 8 is out of bounds for axis 0 with size 3
意为:数组轴(axis)0的大小为3,访问了索引8,导致越界。因为大小为3时此轴只有索引0、1、2。
可以通过print检查,
1是否越界
2数组形状是否符合要求
如果是第二种,可以使用reshape更改数组形状,如:
a=a.reshape(1,9)
【python数组】IndexError: index 8 is out of bounds for axis 0 with size 3
最新推荐文章于 2024-05-08 21:18:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)