How to read an integer value from a binary file?

Jeff Epler jepler at unpythonic.net
Tue May 3 13:50:03 EDT 2005


As your 'for' loop shows, the number of items in the slice [2:5] is only
3, not 4.

Maybe you want the slice [2:6] instead.

>>> x = "xx\xb6/\0\0"
>>> struct.unpack('i', x[2:6])
(12214,)

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050503/9f40663d/attachment.sig>


More information about the Python-list mailing list