擅长:python、mysql、java
<p>变量<code>raw_bytes</code>不是字符串,它的类型是<code>bytes</code>。这就是<code>b</code>前缀的含义。<code>decode</code>是<code>bytes</code>对象的方法,默认编码是UTF-8,但您可以指定其他编码。你知道吗</p>
<p>变量<code>utf_string</code>是一个字符串。<code>encode</code>是一个字符串方法。默认编码是UTF-8,但您可以指定其他编码。你知道吗</p>
<p>正如您所发现的,将这两种方法结合在一起,可以在<code>bytes</code>和表示Unicode码点的字符串之间进行来回转换,前者像字符串一样是不可变的,但是是一个小整数序列。这两种方法在Python<a href="https://docs.python.org/3/library/stdtypes.html" rel="nofollow noreferrer">standard library docs</a>中都有文档记录。你知道吗</p>
<p>Python标准库通常有示例性文档,当您遇到这样的问题时,文档应该是您的第一个调用端口。你知道吗</p>