Binary data handling ?

Bill Loren lorenb2 at bezeqint.net
Mon Sep 1 03:07:41 EDT 2003


Indeed !

thanks !!!

if I use the 'wb' will it work on a unix system, too ?

~B
----- Original Message -----
From: "Tim Roberts" <timr at probo.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Saturday, August 30, 2003 7:11 AM
Subject: Re: Binary data handling ?


> "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.
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list