file.read problem

Fredrik Lundh fredrik at pythonware.com
Fri Feb 17 05:16:54 EST 2006


"wscrsurfdude" wrote:

> >if it's a binary file, open with mode "rb".

> You are right about opening it in the rb mode (flaw in the start post),
> but also when I do this in windows in front of every 0x0A is put a
> 0x0D. I found a explanation why it is working in linux it is below in
> my post.
>
> But what i get of this that in windows in front of every 0x0A is put a
> 0x0D as a line feed. II have to get rid of these.

if you open a file in binary mode ("rb"), you get the data that's in the
file.  no more, no less.  if someone's adding CR to the files, that happens
before you opened them in Python.

have you, perhaps, copied binary files between the systems using FTP
in text mode?  if so, you've damaged the files, and there's no way to fix
them, in general.

</F>






More information about the Python-list mailing list