How do I convert unicode code to string in Python?

python, unicode

Solution

That's just an internal representation. If you print it, you will get what you want:

>>> print("\u0631\u064e\u062c\u0627")
رَجا

In short, this is how Python stores the characters `رَ` and `جا`. If you tell Python to print them, you'll see them converted back to their human-readable form.

Problem

One of my string variables contains unicode code `\u0631\u064e\u062c\u0627`. I want to convert it to a string and see what characters were encoded by it. Is it possible and how can I do it in python?

Original source