IndexError: index 9 is out of bounds for axis 1 with size 9

报错1:IndexError: index 9 is out of bounds for axis 1 with size 9

肯定是下标搞错了,把出问题的代码行,每一个数组下标都检查一下,被赋值的一边也要检查

还有一个类似的报错:index 1 is out of bounds for axis 0 with size 1

a = np.zeros((1, n - 1))  # 调用单个元素要用:a[0][下标]

a = np.zeros(n - 1)  # 调用单个元素要用:a[下标]即可

如果调用方式错误就会报上面的错

你可能感兴趣的:(Python精修,out,of,bounds,np.zeros)