In numpy savetxt function, what does the 'newline' parameter do?

空扰寡人 提交于 2019-12-11 13:59:18

问题


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.


回答1:


It's for setting how the end of a line is represented for interoperability between Mac/Linux/Windows.

Windows typically represents a line end with a carriage return character followed by a linefeed character (\r\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).

Linux has always used a linefeed as far as I know (\n).



来源:https://stackoverflow.com/questions/11267661/in-numpy-savetxt-function-what-does-the-newline-parameter-do

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!