完整错误信息如下:
IndexError: only integers, slices (
:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
经检查,错误之处在索引处使用了浮点数,修改后部分代码如下:
h=int(h) #修改成整型
w=int(w) #修改成整型
return Cluster(h, w,
self.data[h][w][0],
self.data[h][w][1],
self.data[h][w][2])
题记。
本文解决了一个关于使用浮点数作为索引导致的IndexError问题,通过将浮点数转换为整数来修正。

1万+

被折叠的 条评论
为什么被折叠?



