How to join absolute and relative urls?

后端 未结 6 1492
谎友^
谎友^ 2020-12-02 12:07

I have two urls:

url1 = \"http://127.0.0.1/test1/test2/test3/test5.xml\"
url2 = \"../../test4/test6.xml\"

How can I get an absolute url for

6条回答
  •  一个人的身影
    2020-12-02 12:28

    For python 3.0+ the correct way to join urls is:

    from urllib.parse import urljoin
    urljoin('https://10.66.0.200/', '/api/org')
    # output : 'https://10.66.0.200/api/org'
    

提交回复
热议问题