如何使用 Date time id descriptive
0 2017-1-1 12:30 124562 American electronic commerce and cloud computing company based in Seattle
1 2017-1-2 12:40 124565 Amazon has separate retail websites for the United States
2 2017-1-3 12:45 124561 In 2020, Amazon will build a new downtown Seattle building
在单个输出文件中连续保存多个数据?例如,输出文件应包含
numpy
答案 0 :(得分:2)
您只需将打开的文件句柄传递给numpy.savetxt()
:
In [1]: import numpy as np
In [2]: a = np.zeros((3,3))
In [3]: b = np.ones((5,6))
In [4]: with open('mix.txt', 'w') as f:
...: np.savetxt(f, a, fmt='%g')
...: f.write('my comment followed by a new array:\n')
...: np.savetxt(f, b, fmt='%g')
...:
In [5]: !more mix.txt
0 0 0
0 0 0
0 0 0
my comment followed by a new array:
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1