Python urllib.parse.urljoin()
사용 버전 : Python 3.6.8
사용 프로그램 : Atom 1.35.1 x64
파이썬 urllib.parse.urljoin()에 대해서 알아보겠습니다.
괄호 안에는 base, url, allow_fragments가 들어갑니다.
urllib.parse.urljoin()은 'base_url'과 'url'을 URL 형식으로 합쳐줍니다.


기본 URL(https://www.naver.com)에 more.html을 URL 형식으로 합쳐주었습니다.
만약 'url' 속성에 '//'로 시작하는 글자나, 'http://' 또는 'https://' 형식의
글자가 들어가면, base_url 뒤에 붙는 것이 아니라 base_url의 '//' 부분에
들어갑니다.


scheme(http, https)가 붙으면, base_url의 scheme 부분부터 들어갑니다.




allow_fragments 속성을 사용하지 않으면, '#'이 붙어도, 그대로 '/'이 붙은 뒤,
base_url 뒤에 붙습니다.


끝.
카테고리: Python, urllib
댓글
댓글 쓰기
궁금한 점은 댓글 달아주세요.
Comment if you have any questions.