【发布时间】:2018-05-23 07:29:52
【问题描述】:
为什么这个简单的转换不起作用请帮助:
print(getx)
Date
2017-12-08 -4.484884
Name: CCI, dtype: float64
chkccisplt=getx
type(getx)
chksplt=str(getx)
type(chksplt)
print(chksplt)
Date
2017-12-08 -4.484884
Name: CCI, dtype: float64
chkdt,chkcci=chksplt.split(" ")
print(chkdt)
Date
2017-12-08
print(chkcci)
-4.484884
Name: CCI, dtype: float64
chkcci=chkcci.strip()
chkcciflt=float(chkcci)
**ValueError: could not convert string to float: '-4.484884\nName: CCI, dtype:
float64'**
在上面的最后一行中,返回值错误。 提前一千感谢您的所有回答。
【问题讨论】:
-
再次阅读错误信息。字符串
'-4.484884\nName: CCI, dtype: float64'不是正确的浮点数。
标签: python valueerror