【发布时间】:2019-10-24 12:18:50
【问题描述】:
我正在生成一个温度 (T) 数组和另一个位置 (X) 数组,我可以使用简单的命令 plt.plot(X, T) 绘制它。但是,我正在努力将此数据输出到文本文件。 请问,有人可以在这方面帮助我吗?谢谢你。 len(T) 打印 12,len(X) 也打印 12。 这就是我在 Python 中尝试的方式: 这些是while循环后的命令,因此数据已经生成。 我想同时写 T[i] 和 X[i]
with open('Temp.txt', 'w') as fh: # this is where I like to write my Temperature data
for i in range (12): # trying to loop around all the points, up to 12
fh.write(T[i]) # trying to write temperature to the file, and if it works, need to write the same for the position, X.
【问题讨论】:
-
也许this可以帮你把数组的所有成员写入文件
-
感谢您的留言,但这并没有真正帮助。