python模块详解 | urllib
官方文档 - https://docs.python.org/3/library/urllib.html
urllib
is a package that collects several modules for working with URLs:
urllib.request
for opening and reading URLsurllib.error
containing the exceptions raised byurllib.request
urllib.parse
for parsing URLsurllib.robotparser
for parsingrobots.txt
files
urllib.request
urllib.request.urlopen(url,data=None,[timeout, ],cafile=None,capath=None,cadefault=False,context=None)
urllib.parse
urljoin
from urllib.parse import urljoin
url = 'https://chenxuefan.cn'
url = urljoin(url, 'note') # 'https://chenxuefan.cn/note'
quote
from urllib.parse import quote, unquote
ch = '老鼠人'
en = quote(ch) # '%E8%80%81%E9%BC%A0%E4%BA%BA'
ch = unquote(en) # '老鼠人'
[Python对Url内容进行编码][https://blog.csdn.net/vvaa00/article/details/111938257]