我有一些Python代码,可以从文本文件中提取字符串:
[2.467188005806714e-05, 0.18664554919828535, 0.5026880460053854, ....]
Python 代码:
v = string[string.index('['):].split(',')
for elem in v:
new_list.append(float(elem))
这会导致错误:
ValueError: could not convert string to float: [2.974717463860223e-06
为什么无法将[2.974717463860223e-06
转换为浮点数?
[
了吗? - Tim Pietzcker