在:How to write numpy arrays to .txt file, starting at a certain line?
人们帮助我解决了我的问题-这适用于Numpy1.7或更高版本。不幸的是,我不得不使用1.6版的代码(谢谢@Praveen)
extra_text = 'Answer to life, the universe and everything = 42'
header = '# Filexy\n# time operation1 operation2\n' + extra_text
np.savetxt('example.txt', np.c_[time, operation1, operation2],
header=header, fmt='%d', delimiter='\t', comments=''
给我一个Numpy1.6的错误
^{pr2}$对于版本1.6,是否有一个解决方案可以产生相同的结果:
# Filexy
# time operation1 operation2
Answer to life, the universe and everything = 42
0 12 100
60 23 123
120 68 203
180 26 301
你先写你的头,然后你转储数据。 请注意,您将需要在标题的每一行中添加
#
,因为np.savetxt
无法做到这一点。在相关问题 更多 >
编程相关推荐