最佳答案
我试图从不同的部分组成 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'
你能解释这种方法的确切行为吗?