When doing crawlers, sometimes you need to crawl and write Chinese content. However, Chinese characters will be converted to URL characters in the form of %xx in some cases.
such as:
%E7%BE%8E%E5%A5%B3
The above code means "beauty".
The urllib library of Python3 can encode and decode Chinese URLs.
import urllib.parse
cn = input("请输入中文:")
bfb = urllib.parse.quote(cn) # 转为 url 编码
print( bfb )
print( urllib.parse.unquote(bfb) ) # 解码