为什么我不能解码python2.7中的“utf8”字符串?

2024-06-16 14:20:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python写:

'\xF5\x90\x90\x90'.decode('utf8')

但它会出错:

^{pr2}$

字符串\xF5\x90\x90\x90是标准的“utf8”字符串。 它的二进制是11110101 10010000 10010000 10010000。 符合utf8的规则:11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

为什么我不能解码这个字符串?在


Tags: 字符串标准规则二进制utf8解码decodepr2
1条回答
网友
1楼 · 发布于 2024-06-16 14:20:28

来自Wikipedia

In November 2003, UTF-8 was restricted by RFC 3629 to end at U+10FFFF, in order to match the constraints of the UTF-16 character encoding.

您要解码的字符超出此范围。特别是U+150410。在

相关问题 更多 >