【发布时间】:2019-07-19 06:32:52
【问题描述】:
我想将我的 phyton 程序的输出写入一个文本文件。输出在一个循环中,我希望每个输出都在一行中。我正在使用此代码进行编写,但我仍将在一行中给出所有结果。
with open('temp.txt', 'w') as outfile:
out = P2[16:3276,:].sum(axis=0)
outfile.write("{}\n".format(out))
实际结果是:
[ 0. 0. 0. ..., 0. 0. 0.]
但我想变成这样:
0
0
0
0
0
0
【问题讨论】: