0

I got a string from network like:
s = '\u0070\u0079\u0074\u0068\u006f\u006e' or other
when i print(s)
it output '\u0070\u0079\u0074\u0068\u006f\u006e'
I want make '\u' work
when I print(s)
it output 'python' (u'\u0070\u0079\u0074\u0068\u006f\u006e'=python)
what should I do?

ytian
  • 3
  • 3

1 Answers1

0

I don't know if I got what you mean, but if you mean you want convert unicode characters with trailing slashes to real unicode characters, you can use this solution.

for python2 : print s.decode('unicode-escape')

for python3 : print(bytes(s, 'ascii').decode('unicode-escape'))