Search code examples
pythonpython-3.xpython-unicode

Input Unicode character string and output the corresponding character


I have a Python program that stores a dictionary with Unicode number strings in it, then gets the string and prints out the actual character. My code looks like this:

unicodeChars = {'bullet': 'u+2022'}
print(chr(unicodeChars['bullet']))

But when I run the program, it prints out the Unicode character string, (u+2202), not the actual character. How would I make my program do this?

I'm using Python 3 in a Windows 11 64-bit laptop.


Solution

  • The answer was chr(int(unicodeChars['bullet'][2:])). Thank you, @sahasrara62 for the answer!