Binary data handling ?
Tim Roberts
timr at probo.com
Tue Sep 2 11:53:52 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 ?
Tim wrote:
>> 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)
On Mon, 1 Sep 2003 09:07:41 +0200, Bill Loren wrote:
>
>Indeed !
>
>thanks !!!
>
>if I use the 'wb' will it work on a unix system, too ?
Yes. The 'b' is ignored on Unix.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list