如何在Python中解压缩URL引用的UTF-8字符串

如何在Python中解压缩URL引用的UTF-8字符串,python,Python,这将对其进行编码。如何破译它?怎么样 thestring = urllib.quote(thestring.encode('utf-8')) 如果要从utf-8解码字符串,可以先将字符串转换为unicode,然后再转换为任何其他编码(或保留为unicode),如下所示 backtonormal = urllib.unquote(thestring) “忽略”意味着如果遇到不在拉丁字符集中的字符,则忽略该字符。您是否检查了文档中的编码和引号?这难道不是执行字符串.decode('utf-8')

这将对其进行编码。如何破译它?

怎么样

thestring = urllib.quote(thestring.encode('utf-8'))

如果要从utf-8解码字符串,可以先将字符串转换为unicode,然后再转换为任何其他编码(或保留为unicode),如下所示

backtonormal = urllib.unquote(thestring)

“忽略”意味着如果遇到不在拉丁字符集中的字符,则忽略该字符。

您是否检查了文档中的编码和引号?这难道不是执行字符串.decode('utf-8').encode('latin-1','ignore')的一种复杂方式吗??
unicodethestring = unicode(thestring, 'utf-8')
latin1thestring = unicodethestring.encode('latin-1','ignore')