First of all, sorry for my poor and approximate english...
I'm trying to do a Python script, who should retrieve a variable that will represent the unicode code corresponding to an emoji (U000xxxx). The final goal of this part of the program is to have translated, from unicode, in the name of the emoji.
Since I know that in Python to display an emoji it is print("\U000XXXXX")
, so I added the \
before the previous name.
But when I print the final rendering is not the one expected
unicode = "U0001f0cf"
unicode = (f"\{unicode}") #OR# unicode = "\%s" %unicode
print (unicode) #>>> \U0001f0cf
#Expected >>>
I tried a lot of things including .encode()
but Python told me I couldn't use a string pattern on an object of type bytes (?)
This is the part that is causing me problem, all the rest of the process is ok... To translate the name of the emoji, from unicode, I found this method (crafted from another Stackoverflow topic)
name = emojis.decode(unicode).replace("_"," ").replace(":","")
print(name) #>>> \U0001f0cf
Whereas if I directly enter the unicode code it works...
name = emojis.decode("U0001f0cf").replace("_"," ").replace(":","")
print(name) #>>> :black_joker:
Thank you very much to anyone who will try to help me, Have a good evening