0

When I do this

print >>file, "\n"

This actually writes a "\r\n" on my Windows machine. How do I write only the "\n" char and not the "\r"?

DarthRubik
  • 3,927
  • 1
  • 18
  • 54
  • 1
    You can see some discussion on this [here](http://stackoverflow.com/questions/4599936/handling-r-n-vs-n-newlines-in-python-on-mac-vs-windows) – nbryans Jun 14 '16 at 21:30
  • 3
    That's not going to write `'\r\n'`. It might write `'\n\r\n'` or `'\r\n\r\n'`, depending on whether you opened the file in text or binary mode, but not `'\r\n'`. (Also, you probably want binary mode.) – user2357112 Jun 14 '16 at 21:32
  • nbryans is correct. You want either the universal newlines or newline='\n' when you open the file – Hugh Fisher Jun 15 '16 at 00:01

0 Answers0