python模块详解 | urllib

官方文档 - https://docs.python.org/3/library/urllib.html

urllib is a package that collects several modules for working with URLs:

urllib.request

urllib.request.urlopen(url,data=None,[timeout, ],cafile=None,capath=None,cadefault=False,context=None)

urllib.parse

  1. urljoin
from urllib.parse import urljoin

url = 'https://chenxuefan.cn'
url = urljoin(url, 'note')  # 'https://chenxuefan.cn/note'
  1. 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]


175 字

Powered By Valine
v1.5.2