Python presents you with a representation of the byte string that you can copy and paste into a Python interpreter again.
In order to make it readable and survive pasting into something that doesn't handle raw bytes, anything that isn't printable is escaped using a Python byte escape code, \xHH
, representing the hexademical value for a byte.
Anything that is printable, is represented as the ASCII character directly. A hex byte 0x41 is the letter A
(capital) in ASCII, and printed as such:
>>> b'\x41'
b'A'
Thus, *
is hex 2A, /
is hex 2F:
>>> hex(ord(b'*'))
'0x2a'
>>> hex(ord(b'/'))
'0x2f'
You could use binascii.hexlify()
to generate an all-hexadecimal representation of your bytes:
>>> from binascii import hexlify
>>> hexlify(b'\xff\xd8\xff\xe1/\xfeExif\x00\x00MM\x00*\x00\x00\x00\x08\x00\x0b\x01\x0f\x00\x02\x00\x00\x00\x06\x00\x00')
b'ffd8ffe12ffe4578696600004d4d002a00000008000b010f0002000000060000'
That said, you would be better off installing Pillow (the modernized fork of the Python Image Library) and have it handle JPEG images, including extracting EXIF information, for you.