from urllib.parse import urljoin, urlparse
url = 'http://example.com/cxs?name=cxs#age'
urljoin(url, urlparse(url).path)
>>> 'http://example.com/cxs'
Python url去除参数、分段,提取出纯链接
于 2021-07-01 14:37:37 首次发布
from urllib.parse import urljoin, urlparse
url = 'http://example.com/cxs?name=cxs#age'
urljoin(url, urlparse(url).path)
>>> 'http://example.com/cxs'