相关疑难解决方法(0)

Python:与urljoin的混淆

我试图从不同的部分形成URL,并且无法理解此方法的行为.例如:

Python 3.x

from urllib.parse import urljoin

>>> urljoin('some', 'thing')
'thing'
>>> urljoin('http://some', 'thing')
'http://some/thing'
>>> urljoin('http://some/more', 'thing')
'http://some/thing'
>>> urljoin('http://some/more/', 'thing') # just a tad / after 'more'
'http://some/more/thing'
urljoin('http://some/more/', '/thing')
'http://some/thing'
Run Code Online (Sandbox Code Playgroud)

你能解释一下这种方法的确切行为吗?

python python-3.x

47
推荐指数
2
解决办法
3万
查看次数

标签 统计

python ×1

python-3.x ×1