Python url去除参数、分段,提取出纯链接

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)