在numpy savetxt函数中,"newline"参数有什么作用? [英] In numpy savetxt function, what does the 'newline' parameter do?
问题描述
我正在使用savetxt函数(说明此处)将矩阵保存到txt文件,而我想知道'newline'参数有什么作用?同样,"header"参数似乎不适用于最新的numpy版本.
I'm using the savetxt function (description here) to save a matrix to a txt file, and I wonder what does the 'newline' parameter do? Also the 'header' parameter doesn't seem to work with the latest numpy version.
推荐答案
它用于设置行尾如何表示Mac/Linux/Windows之间的互操作性.
It's for setting how the end of a line is represented for interoperability between Mac/Linux/Windows.
Windows通常代表一个带有回车符和换行符(\ r \ n)的行尾.
Windows typically represents a line end with a carriage return character followed by a linefeed character (\r\n).
Mac过去仅使用回车符,许多Microsoft Mac软件仍然以这种方式保存文件,但是在过去的十年左右的时间里一直使用换行符(\ n).
Mac used to use just a carriage return, and much Microsoft Mac software still saves files this way, but has used a linefeed for the past decade or so (\n).
据我所知(\ n),Linux一直使用换行符.
Linux has always used a linefeed as far as I know (\n).
这篇关于在numpy savetxt函数中,"newline"参数有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!