Byte reading problem...

I’m writing my first script that reads bytes instead of text. It’s an importer, and so far I’ve been able to get all the mesh components into Blender. The problem I’m having is there is a bone list, which is 32bit hashes of the bone names. This is an example of a list of 14 bones:

d0 95 e1 85 b6 06 10 63 78 b0 f3 a6 00 a4 80 ec
5e 5e 03 c6 7b d2 c4 d0 1a 18 6b 55 15 d9 23 e7
66 62 a9 6f 6a 54 de 4c cf 05 ac af 5c 35 b1 83
de 30 b3 81

When I read these into Blender I get this:

[b'\xd0', b'\x95', b'\xe1', b'\x85', b'\xb6', b'\x06', b'\x10', b'c', b'x', b'\x
b0', b'\xf3', b'\xa6', b'\x00', b'\xa4', b'\x80', b'\xec', b'^', b'^', b'\x03',
b'\xc6', b'{', b'\xd2', b'\xc4', b'\xd0', b'\x1a', b'\x18', b'k', b'U', b'\x15',
 b'\xd9', b'#', b'\xe7', b'f', b'b', b'\xa9', b'o', b'j', b'T', b'\xde', b'L', b
'\xcf', b'\x05', b'\xac', b'\xaf', b'\\', b'5', b'\xb1', b'\x83', b'\xde', b'0',
 b'\xb3', b'\x81', b'\x80', b'J', b'S', b'\xdd']

It looks like there a conversion happening or something. :frowning: How can I read this data ‘as is’?

I think you need to decode this bytes:

Thanks, but that gives the same result. For example, b’\x69’ comes out as ‘i’.

can you re-explain your problem?

assuming that you don’t actually have spaces between the bytes and your binary files are big endian.

data = io.BytesIO(data)
bone_hashes = []
for i in range(num_bones):
   bone_hash = struct.unpack(">L",

reverse the direction of the Arrow for little endian.
this will create a list of 14 32bit integers. Have I understood your question properly

Thanks for your answers. What I mean is if the bytes are “xd0, x95, xe1, x85”, I want “d095e185” (some bytes are getting converted to other characters). I got it to work by using bytes.ord(), but if there’s a more elegant way, I’d be happy to try it.