Get unicode code point of a character using Python

后端 未结 5 1232
余生分开走
余生分开走 2020-12-04 20:54

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.

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 21:30

    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.

提交回复
热议问题