Python报错:
IndexError: index 0 is out of bounds for axis 0 with size 0
原因:
索引超出了列表的长度
import numpy as np a = np.empty(1) print(a[1]) # IndexError: index 1 is out of bounds for axis 0 with size 1
或者
import numpy as np a = np.empty(3) print(a[5]) # IndexError: index 5 is out of bounds for axis 0 with size 3
解决方法:
检查是自己的索引错了, 还是数组长度定义错了