Python 有一个转义序列 \u
来显示 unicode 值。但是,这仅限于 16 位 unicode 值。那就是
>>> '\u1020'
'ဠ'
而 32 位解码值不起作用。也就是
>>> '\u00001000'
'\x001000'
这显然是错误的。 python documentation提及
The escape sequence \u0020 indicates to insert the Unicode character with the ordinal value 0x0020 (the space character) at the given position.
最佳答案
python How To Unicode明确提到使用 '\U'
来表示 32 位 unicode 序列。
>>> "\u0394" # Using a 16-bit hex value
'Δ'
>>> "\U00000394" # Using a 32-bit hex value
'Δ'
在这种情况下
>>> '\U00001000'
'က'
关于python - python 中的 32 位 unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27702983/