Python urlencode()

urlencode - Convert a mapping object or a sequence of two-element tuples to a percent-encoded string.

Function

urllib.urlencode( query [, doseq ] )

Parameters

query - When a sequence of two-element tuples is used as the query argument, the first element of each tuple is a key and the second is a value.
doseq - If set to true, inh2idual key=value pairs separated by '&' are generated for each element of the value sequence for the key.

Return value

Returns a url encoded string

Example

>>> import urllib
>>> params = urllib.urlencode( {'param': 'url encoder'} )
>>> print "http://example.com/?" + params

Output

http://example.com/?param=url+encoder

Github

See also: