本文介绍了标题行开头没有哈希标记的numpy.savetxt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试保存带有标题的矩阵时,第一行上会出现一个井号和一个空格(#):
When I try to save a matrix with header, a hash mark and a space (# ) appear on the first line:
输入:
np.savetxt(filename,data, fmt='%i %i %i %i %s',delimiter='\t',header="a\tb\tc\td\te")
输出:
# a b c d e
0 0 0 0 bla
0 0 0 0 bla
1 1 1 1 bla
1 1 1 1 bla
有人暗示为什么吗?我如何删除它?
Any hint why? How could I remove it?
推荐答案
它插入#,因为该行是注释,注释的默认字符是符号#,您可以在文档中阅读.
it inserts the # because that line is a comment, and the default character for comments is the symbol #, as you can read in the documentation here.
如果要摆脱它,请将comments=''
作为选项传递给savetxt.
If you want to get rid of it, pass comments=''
as option to savetxt.
这篇关于标题行开头没有哈希标记的numpy.savetxt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!