Get unicode code point of a character using Python

SK9 picture SK9 · Sep 3, 2011 · Viewed 53.1k times · Source

In Python API, is there a way to extract the unicode code point of a single character?

Edit: In case it matters, I'm using Python 2.7.

Answer

Keith picture Keith · Sep 3, 2011

If I understand your question correctly, you can do this.

>>> s='㈲'
>>> s.encode("unicode_escape")
b'\\u3232'

Shows the unicode escape code as a source string.