How to write Unix end of line characters in Windows using Python

Posted by tttppp on Stack Overflow See other posts from Stack Overflow or by tttppp
Published on 2010-03-29T08:17:22Z Indexed on 2010/03/29 8:23 UTC
Read the original article Hit count: 278

Filed under:
|

How can I write to files using Python (on Windows) and use the Unix end of line character?

e.g. When doing:

f = open('file.txt', 'w')
f.write('hello\n')
f.close()

Python automatically replaces \n with \r\n.

© Stack Overflow or respective owner

Related posts about python

Related posts about newline