Combine relative path with absolute path in Python

---
date: Aug 12, 2017
tags:
-
---

Recently I need to combine a absolute link with a relative link, so I tried to hard code it but failed. After checking online, there is actually a lib in Python called urlparse that have a function to combine this kind of url. the use is also simple:

1
2
3
from urlparse import urljoin
urljoin('http://mysite.com/foo/bar/x.html', '../../images/img.png')
#'http://mysite.com/images/img.png'

Navigation

Not the Footnote

The site is proudly powered by Hexo and using a site strcuture from the Hexo theme called Nayo.

The site is powered by the glorious CSS from bettermotherf**kingwebsite.com with some tweaks. Censored the f-word for good.

This site is hosted on Digital Ocean. Deploy your next app in seconds. Get $100 in cloud credits from @DigitalOcean using my link.

Custom Stickers, Die Cut Stickers, Bumper Stickers - Sticker Mule

Possibly the Footnote

Main | Access | RSS | Sitemap
2008 - 2020 | Patrick WU Jinming