将以%号开头的gb2312编码转化为汉字
解码
import urllib.parse
mao = '%C3%AB%CF%FE%CD%AE' #此编码格式为gb2312
mao = urllib.parse.unquote(mao,encoding='gb2312') #urllib.parse.unquote()的默认编码格式为‘utf-8’
print(mao)
guan = '%E5%85%B3%E6%99%93%E5%BD%A4' #此编码格式为utf-8
guan = urllib.parse.unquote(guan)
print(guan)
毛晓彤
关晓彤
编码
mao = '毛晓彤'
mao = mao.encode('gb2312') #如果编码格式为utf-8,那么这一步可以省略
mao = urllib.parse.quote(mao)
print(mao)
guan = '关晓彤'
guan = urllib.parse.quote(guan) #默认编码格式为utf-8
print(guan)
%C3%AB%CF%FE%CD%AE
%E5%85%B3%E6%99%93%E5%BD%A4