我现在正在用python编程心电信号,我有这个错误,我不知道如何解决它。
ValueError:无法将字符串转换为浮动:'-0,274697\n‘

发布于 2017-02-02 23:08:14
好的,您正在尝试将带有,的字符串转换为浮点数。
在Python中,您的数字中不能有逗号,只支持.。要转换它,可以使用以下行
datei= open(dateiname,'r')
dateistr = datei.readline().replace(',','.') #replacing comma with .
dateistr = dateistr.replace('#','') # replacing # with blank
dateistr = dateistr.strip('\n') #remove the new line character at the end
return float(dateistr)https://stackoverflow.com/questions/42013867
复制相似问题