Python 错误问题:TypeError:';浮动';对象没有属性'__获取项目'; 回溯(最近一次呼叫最后一次): 文件“vehicle detection.py”,第51行,在 R=[R表示R中的R,如果R[0]位于['car','bus']] TypeError:“float”对象没有属性“\uuuu getitem\uuuu” bname=basename(拆分文本(img_路径)[0]) R、 _u=检测(车辆网络、车辆元、img路径、阈值=车辆阈值) R=[R表示R中的R,如果R[0]位于['car','bus']]

Python 错误问题:TypeError:';浮动';对象没有属性'__获取项目'; 回溯(最近一次呼叫最后一次): 文件“vehicle detection.py”,第51行,在 R=[R表示R中的R,如果R[0]位于['car','bus']] TypeError:“float”对象没有属性“\uuuu getitem\uuuu” bname=basename(拆分文本(img_路径)[0]) R、 _u=检测(车辆网络、车辆元、img路径、阈值=车辆阈值) R=[R表示R中的R,如果R[0]位于['car','bus']],python,tensorflow,Python,Tensorflow,__getitem__ 在类中,允许其实例使用[](索引器)运算符。 list类正在实现它,因此我们编写的代码看起来像num=my_lst[0] 但是,您似乎试图对浮点数而不是列表使用[]运算符。是列表、字符串还是数字?r[0]可能导致此错误。 Traceback (most recent call last): File "vehicle-detection.py", line 51, in <module> R = [r for r in R if r[0] in [

__getitem__

在类中,允许其实例使用[](索引器)运算符。 list类正在实现它,因此我们编写的代码看起来像
num=my_lst[0]

但是,您似乎试图对浮点数而不是列表使用
[]
运算符。

是列表、字符串还是数字?
r[0]
可能导致此错误。
Traceback (most recent call last):
  File "vehicle-detection.py", line 51, in <module>
    R = [r for r in R if r[0] in ['car','bus']]
TypeError: 'float' object has no attribute '__getitem__'


bname = basename(splitext(img_path)[0])

R, _ = detect(vehicle_net, vehicle_meta, img_path ,thresh=vehicle_threshold)

R = [r for r in R if r[0] in ['car','bus']]