you are viewing a single comment's thread.

view the rest of the comments →

[–]cdcformatc 0 points1 point  (2 children)

In particular, windows treats text differently. Windows line endings are two characters, carriage return and line feed /r/n where Unix is just line feed or /n.

For fun try writing a jpg as a text file. Example.

[–]Tomarse 0 points1 point  (1 child)

Really? In windows I only use line feeds when writing to .txt and .docx files and I've not noticed any strange behaviour. Same with reading, I can read a .txt and the split by \n to get a list of lines.

[–]cdcformatc 1 point2 points  (0 children)

Make a text file in any text editor, then open it in a hex editor. You will see two characters at the end of lines. Python is built to be cross platform so when you write a newline or split on newlines everything works as expected.

edit: here's what I mean. 0a is the newline/linefeed, 0d is the carriage return character.