How does one print a Unicode character code in Python?

前端 未结 1 1300
南笙
南笙 2021-02-07 11:48

I would like to print a unicode\'s character code, and not the actual glyph it represents in Python.

For example, if u is a list of unicode characters:

相关标签:
1条回答
  • 2021-02-07 12:40

    For printing raw unicode data one only need specify the correct encoding:

    >>> s = u'\u0103'
    >>> print s.encode('raw_unicode_escape')
    \u0103
    
    0 讨论(0)
提交回复
热议问题