Python报错:
IndexError: index 0 is out of bounds for axis 0 with size 0
原因:
索引超出了列表的长度。
eg1:
import numpy as npa = np.empty(1)print(a[1])# IndexError: index 1 is out of bounds for axis 0 with size 1
eg2:
import numpy as npa = np.empty(3)print(a[5])# IndexError: index 5 is out of bounds for axis 0 with size 3
解决方法:
检查是自己的索引错了, 还是数组长度定义错了。
来源地址:https://blog.csdn.net/sweet_tea_/article/details/128514919