问题
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