Binary data handling ?

Tim Roberts timr at probo.com
Sat Aug 30 01:11:04 EDT 2003


"Bill Loren" <lorenb2 at bezeqint.net> wrote:
>
>I'm having difficulties to accomplish some simple chores with binary data.
>I'm having a string (?) which I received via an HTTP transactions which is a
>binary file.
>Problem is the webserver I'm communicating with injected a \x0D before every
>\x0A,
>and I need to remove those 0x0D characters from my buffer before saving it
>to disk.
>
>any ideas ?

I'll bet you real money that the problem is not in the web server.  I'd
wager that the string is correct when you receive it, but that you are
writing it to file like this:
   file('out.txt','w').write(download)

On a Windows system, that'll turn all the LFs into CR-LFs.  Use this
instead:
   file('out.txt','wb').write(download)
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.




More information about the Python-list mailing list