-1

I have a list of string of gujarati unicode characters and i want to convert them to unicode. But the problem is the escape character('').
for eg

a="\\u0aec"
print(type(a))
# <type 'str'>

How to convert it into Unicode which is ('\u0aec')?
Also don't think about using .encode('utf-8') as it will just make it a unicode string and not unicode characters.

sparsh goil
  • 33
  • 1
  • 7
  • Don't understand the question - this _is_ unicode (you can write r"\u0aec" if you don't want the backslash shown escaped). Each string in Python3 is Unicode (e.g. consists of unicode characters). – MrBean Bremen Jul 31 '20 at 10:51
  • Note that if you print a `list` of such strings (`print(my_list_of_strings)`), the escaped form (in fact, the repr) of each string will be printed. If you were to print each string separately (`for s in my_list_of_strings:print(s)`), the unescaped forms will be printed, fonts and terminal configuration permitting. – snakecharmerb Aug 16 '20 at 14:32

1 Answers1

0
a=u"\u0aec"

Read the docs:

There are more articles about the key differences between Python 2.7.x and Python 3.x; for instance Unicode:

Python 2 has ASCII str() types, separate unicode(), but no byte type.

Now, in Python 3, we finally have Unicode (utf-8) strings, and 2 byte classes: byte and bytearrays.

JosefZ
  • 28,460
  • 5
  • 44
  • 83