file read, binary or text mode

Askari askari at addressNonValide.com
Fri Sep 24 07:31:13 EDT 2004


"Guyon Morée" <gumuz at NO_looze_SPAM.net> wrote in
news:41540121$0$3891$4d4ebb8e at news.nl.uu.net: 

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

"rb" and "r" on a text file is the same if your text file have ascii 
caractere (8bit) but it's not the same for Unicode caractere (16 bit).
Bref, if you sure that your file is ONLY text, use "r",  else, use always 
"rb".  And "r" don't read the control caractere other that "\n" "\t" .. etc




More information about the Python-list mailing list