TypeError: slice indices must be integers or None or have an __index__ method

在做人脸特征点检测时用python写的如下几行代码,一直运行有问题。

运行一直报 所划红线所在行出现“ TypeError: slice indices must be integers or None or have an __index__ method”的错误,百度了一下,网上大概分析造车这个错误的原因是 数据的格式问题。

可能存在问题1:

如错误是出现在带除法的那行,那么需要你将除法符号" /"更改成“ //”。


可能存在问题2:
跟我问题一样,如下,“[]”中的数据变成了浮点数,不能作为数组的下标了,需要将数据强制转换为int整型类型。即int(你要转换的数据)

参考:
http://www.mobibrw.com/2017/7322
https://stackoverflow.com/questions/42646915/typeerror-slice-indices-must-be-integers-or-none-or-have-an-index-method

猜你喜欢

转载自blog.csdn.net/c20081052/article/details/80576035