Search code examples
pythonunicodeutf-8

Form unicode character from label


I have a simple syntax related question that I would be grateful if someone could answer. So I currently have character labels in a string format: '0941'.

To print out unicode characters in Python, I can just use the command:

print(u'\u0941')

Now, my question is how can I convert the label I have ('0941') into the unicode readable format (u'\u0941')?

Thank you so much!


Solution

  • >>> chr(int('0941',16)) == '\u0941'
    True