CCing the list.
Please use Reply All when responding.
> I am still little confused since I was under the impression,
> that if a c program was able to write this binary code,
> then if we know how c "packed" the data/string then
> we able to decode/unpack it using python.
Thats correct but y
"Alan Gauld" <[EMAIL PROTECTED]> wrote
>>>>>first = struct.unpack('', '\x02\x00')
>> error: unpack requires a string argument of length 4
>
> And here you asked for 54 characters but only gave
> it two bytes. And the two byes were 02 and 00 which
> are not printable characters.
Oo
Nirmal Sakthi wrote:
> I am using module struct.unpack() to decode data from a binary file,
> so that I can use the value in a calculation.
>
> I have been able to extract an integer value.
>
> >>>length = struct.unpack('i', '\x9c\x00\x00\x00')
> >>>length = int(length[0])
> >>>
"Nirmal Sakthi" <[EMAIL PROTECTED]> wrote
> I want to be able to extract a string.
>
> I have tried,
>
>>>>first = struct.unpack('s', '\x02\x00')
>>>>first = str(first[0])
>>>>print first
>Traceback (most recent call last):
> ..
>error: unpack requires a string argument of
I am using module struct.unpack() to decode data from a binary file, so that
I can use the value in a calculation.
I have been able to extract an integer value.
>>>length = struct.unpack('i', '\x9c\x00\x00\x00')
>>>length = int(length[0])
>>>print length
156
I want to be able