I have a simple code:
f = open('out.txt','w') f.write('line1\n') f.write('line2') f.close()
The code works in windows and gives a file size of 12 bytes , and linux gives 11 bytes The reason is a new line
On linux, it's \n , and for win, it's \r\n
But in my code, I am specifying a new line as \n . The question is, how can I get python to support the new line as \n always, and not check the operating system.
python newline
user1148478 Feb 07 2018-12-21T00: 00Z
source share