ValueError: could not convert string to float的处理方式

xiaoxiao2021-02-27  202

平台:PyCharm

遇到如下问题:    

data.append([float(tk) for tk in tokens[:-1]])

ValueError: could not convert string to float

原因:很可能是你的数据中含有\t,即退格键

解决办法:

1、选择任意两个数据之间间隙

2、CTRL+R

3、替换为一个空格

我本来想用正则表达式匹配,不过实在是没弄出来。索性就自己动手了。
转载请注明原文地址: https://www.6miu.com/read-10346.html

最新回复(0)