ValueError: could not convert string to float: ‘““‘ 报错原因

在测试代码过程中,报出下面的错误:
ValueError: could not convert string to float: ‘""’
回来定位到出错的地方
ValueError: could not convert string to float: ‘““‘ 报错原因_第1张图片
出错代码段

字面意思:数值错误:无法把字符串转换为浮点数:“”
再翻译一下:就是说你想转换为浮点数的字符串中有的字符串转换不了,即不是数字

这和之前报错有些类似:

print(float(‘B’))
输出:
Traceback (most recent call last):
File “main.py”, line 2, in
print(float(‘B’))
ValueError: could not convert string to float:B

查找open函数后 可以知道输入的是字符串型路径
经过打印idx 是数据对应的序号
发现输入的字段错误 应该为train_list

你可能感兴趣的:(Bug,python,开发语言,后端,pytorch)