Python3-URL中的中文编码与解码

1、网址链接中的中文编码

  • 中文的gbk(GB2312)编码: 一个汉字对应两组%xx,即%xx%xx
  • 中文的UTF-8编码: 一个汉字对应三组%xx,即%xx%xx%xx

2、编码:

1 from urllib.parse import quote
2 text = quote(text, 'utf-8')

3、解码:

1 from urllib.parse import unquote
2 text = unquote(text, 'utf-8')

 4、python的编码解码知识:

待更新