You can:
- Remove
\x -es - Use .decode ('hex') in the resulting string
the code:
>>> '\\xF3\\xBE\\x80\\x80'.replace('\\x', '').decode('hex') '\xf3\xbe\x80\x80'
Pay attention to the appropriate interpretation of backslashes. When the string representation is "\ xf3", this means a single-byte string with a byte value of 0xF3. When this is "\\ xf3", which is your input, it means the string consists of 4 characters: \ , x , f and 3
Eli bendersky
source share