1import urllib.parse
2query = 'Hellö Wörld@Python'
3print(urllib.parse.quote(query))
4 >> 'Hell%C3%B6%20W%C3%B6rld%40Python'
1>>> import urllib
2>>> f = { 'eventName' : 'myEvent', 'eventDescription' : 'cool event'}
3>>> urllib.urlencode(f)
4'eventName=myEvent&eventDescription=cool+event'
5
1>>> from urllib.parse import urljoin
2>>> urljoin('/media/path/', 'js/foo.js')
3'/media/path/js/foo.js'
4
1#Python3
2import urllib
3print (urllib.parse.quote('gitlab/gith', safe=''))
4>>> gitlab%Fgith
1>>> urllib.parse.urlparse("http://example.com/pa/th;param1=foo;param2=bar?name=val#frag")
2ParseResult(scheme='http', netloc='example.com', path='/pa/th', params='param1=foo;param2=bar', query='name=val', fragment='frag')
3