Using string-escape
or unicode-escape
encoding:
>>> content = r'\xe87\x00\x10LOL'
>>> print content
\xe87\x00\x10LOL
>>> content
'\\xe87\\x00\\x10LOL'
>>> content.decode('string-escape')
'\xe87\x00\x10LOL'
>>> map(hex, map(ord, content.decode('string-escape')))
['0xe8', '0x37', '0x0', '0x10', '0x4c', '0x4f', '0x4c']
>>> bytes(map(ord, content.decode('string-escape')))
'[232, 55, 0, 16, 76, 79, 76]'
>>> bytearray(map(ord, content.decode('string-escape')))
bytearray(b'\xe87\x00\x10LOL')