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