Python: urllib.parse.urljoin VS string concatenation

24 Views Asked by At

Could you please explain to me the difference between two approaches of url formatting : concatenation and urllib.parse.urljoin and which is better to use?

# base_url = "http://example.com"
# url_path = "/ssome/endpoint"
from urllib.parse import urljoin
url = urljoin(base_url, url_path)

VS

url = base_url + url_path

Thank you

0

There are 0 best solutions below