当我向文本文件写入数组时,我想向它添加一个标题:
np.savetxt('output.txt', array, header = str(dimension))
但在默认情况下,Python在头部前面添加了#。不管怎么说,我能摆脱它吗?
发布于 2014-04-17 03:21:43
作为numpy.savetxt,comment优先于header。
所以,试试
np.savetxt('output.txt', array, header=str(dimension), comments='')发布于 2018-07-25 15:25:09
np.savetxt(BASEPATH+ r'keywordsarray2.txt', df1.values,
fmt='%4.d', header=str(df1.columns))https://stackoverflow.com/questions/23123879
复制相似问题