urllib
import urllib.parse def __get_url(self, path): return urllib.parse.urljoin(self.__endpoint, path)
>>>from urllib.parse import urljoin
>>>urljoin("http://www.chachabei.com/folder/currentpage.html", "anotherpage.html")'
输出 http://www.chachabei.com/folder/anotherpage.html'
>>>urljoin("http://www.chachabei.com/folder/currentpage.html", "/anotherpage.html")'
输出 http://www.chachabei.com/anotherpage.html'
第二个参数将第一个参数最后一节替换掉