Search code examples
pythonutf-8decodeencode

\\x to \x with python


I have a string like this:

'\\xac\\x85'

and I want to encode these string like this another:

'\xac\x85'

I tried a lot of things like encode tu utf-8, replace \\x, etc. But when I print the result it always is with \\x.

Any idea?


Solution

  • '\\xac\\x85' is the literal representation of '\xac\x85'. So you dont have to do any translation

    >>> print ('\\xac\\x85')
    \xac\x85