Manipulating binary data in Python

Posted by Dominic Bou-Samra on Stack Overflow See other posts from Stack Overflow or by Dominic Bou-Samra
Published on 2010-06-17T06:12:41Z Indexed on 2010/06/17 6:23 UTC
Read the original article Hit count: 256

Filed under:
|
|

I am opening up a binary file like so:

file = open("test/test.x", 'rb')

and reading in lines to a list. Each line looks a little like:

'\xbe\x00\xc8d\xf8d\x08\xe4.\x07~\x03\x9e\x07\xbe\x03\xde\x07\xfe\n'

I am having a hard time manipulating this data. If I try and print each line, python freezes, and emits beeping noises (I think there's a binary beep code in there somewhere). How do I go about using this data safely? How can I convert each hex number to decimal?

© Stack Overflow or respective owner

Related posts about python

Related posts about binary