Python中是否有类似这样的库?
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "anotherpage.html")
'http://www.asite.com/folder/anotherpage.html'
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "folder2/anotherpage.html")
'http://www.asite.com/folder/folder2/anotherpage.html'
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "/folder3/anotherpage.html")
'http://www.asite.com/folder3/anotherpage.html'
>>> resolvePath("http://www.asite.com/folder/currentpage.html", "../finalpage.html")
'http://www.asite.com/finalpage.html'
urljoin("http://example.com/blah.html", "./././whoa.html")
会删除点,而urljoin("http://example.com/blah.html", "/./././whoa.html")
则不会。 - obskyrurllib.parse.uses_relative
和urllib.parse.uses_netloc
以包括您的方案,如果您想使其工作。关于全局状态方面不太美观,但我没有看到其他方法可以在不修补标准库的情况下完成此操作。 - user8866053