首页 > 编程语言 >python遇到IndexError: only integers, slices (`:`), ellipsis (`...`)……

python遇到IndexError: only integers, slices (`:`), ellipsis (`...`)……

时间:2022-10-27 13:37:19浏览次数:48  
标签:integers IndexError slices int self only ellipsis data


完整错误信息如下:

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])

题记。


标签:integers,IndexError,slices,int,self,only,ellipsis,data
From: https://blog.51cto.com/u_15847885/5800883

相关文章