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:
\xhh is the character with hex value hh. Other characters such as .
and `~' are normal characters.
Iterating on a string gives you the characters in it, one at a time.
ord(c) will return an integer representing the character. E.g., ord('A') == 65
.
This will print the decimal numbers for each character:
s = '\xbe\x00\xc8d\xf8d\x08\xe4.\x07~\x03\x9e\x07\xbe\x03\xde\x07\xfe\n'
print ' '.join(str(ord(c)) for c in s)