file read, binary or text mode

Roel Schroeven rschroev_nospam_ml at
Fri Sep 24 08:12:19 EDT 2004

Guyon Morée wrote:
> what is the difference?

On Unix/Linux, none.

On Windows, binary mode is just that while text mode translates "\r\n" 
(or "\n\r", I always forget) to "\n" on input and vice-versa on output.

I don't know about other platforms.

> if I open a text file in binary (rb) mode, it doesn't matter... the read()
> output is the same.

Depends on your platform, and the format of the text file (Unix, Windows 
or other platform style line endings).

"Codito ergo sum"
Roel Schroeven

More information about the Python-list mailing list