【发布时间】:2017-02-01 14:08:31
【问题描述】:
我想通过读取这些数字并将其放入 y 列表中以科学计数法绘制数字。这是我的代码。
import matplotlib.pyplot as plt
import csv
x = []
y = []
with open('test1.txt','r') as csvfile:
plots = csv.reader(csvfile, delimiter='\t')
for row in plots:
x.append(float(row[0]))
y.append(float(row[1]))
plt.plot(x,y, label='20 Volt max with filter')
plt.xlabel('time')
plt.ylabel('voltage')
plt.show()
.txt 文件如下所示:
0 -1,89E-09
0,001 -1,37E-08
0,002 -5,69E-08
错误是:
ValueError: could not convert string to float: '-1,89E-09'
【问题讨论】:
-
请添加一个标签,表明您使用的语言。另外,您实际上还没有问过问题。
-
我正在使用 Spyder (Python 3.5) 我的问题是我得到 ValueError: could not convert string to float: '-1,89E-09'
-
该信息需要在问题中。添加一个“python”标签(可能有一个单独的“python3”标签),并在问题中显示确切的错误消息。 (我很确定我知道问题出在哪里,但我还不打算发布答案。)
-
感谢您的回复。我试图编辑以使我的问题易于理解
-
错误信息和您要问的问题应该在问题的正文中。我已经为你更新了。
标签: string python-3.5 scientific-notation