Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert unicode code to string in Python?

Tags:

python

unicode

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?

like image 317
minerals Avatar asked Mar 21 '23 00:03

minerals


1 Answers

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.

like image 77
aIKid Avatar answered Apr 02 '23 08:04

aIKid