parse binary file
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sun Jan 29 08:53:07 EST 2012
On Sun, 29 Jan 2012 13:39:25 +0100, Peter Otten wrote:
> contro opinion wrote:
>
>> please download the attachment ,and put in c:\test.data
>
> Your data didn't make it through.
Since this is a text-only newsgroup, it won't.
>> and run the folloeing code:
>>
>> from struct import unpack
>> file_obj = open('c:\\test.data', 'r')
>
> Open the file in binary mode to disable CRNL-to-NL translation which
> will corrupt your binary data.
[...]
>> why i can't parse all of them??i just can get a small part of them.
>
> I believe a '\x1a' byte marks the end of a text file. Maybe you've run
> into one of these.
That's Windows only, and only when reading in text mode.
--
Steven
More information about the Python-list
mailing list