我试图从不同的部分形成URL,并且无法理解此方法的行为。例如:Python:与urljoin混淆
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'
你能解释一下这种方法的具体行为?
请注意这些问题:上述导入语句适用于Python 3.x.对于python 2.x,使用“from urlparse import urljoin”。 –