urlparse.urljoin を使う。
>>> import urlparse >>> base = "http://www.example.com/foo/bar/baz.html" >>> relative = "../hoge/fuga.html" >>> urlparse.urljoin(base, relative) 'http://www.example.com/foo/hoge/fuga.html'
takatoh's blog – Learning programming languages.
urlparse.urljoin を使う。
>>> import urlparse >>> base = "http://www.example.com/foo/bar/baz.html" >>> relative = "../hoge/fuga.html" >>> urlparse.urljoin(base, relative) 'http://www.example.com/foo/hoge/fuga.html'