python - How to use urllib.urlencode? What are the the type of those two variables -
if :
postdata = urllib.urlencode({ 'zip':'98105', 'zipcode':'98115' })
for 'zip', type of 'first position variable'. html id, or html class, or what? '98105', value trying change?
urlencode creates "websafe" urls you.
postdata = urllib.urlencode({ 'zip':'98105', 'zipcode':'98115' })
in case postdata equals 'zipcode=98115&zip=98105'
convert mapping object or sequence of two-element tuples “percent-encoded” string, suitable pass urlopen() above optional data argument. useful pass dictionary of form fields post request. resulting string series of key=value pairs separated '&' characters, both key , value quoted using quote_plus() above. when sequence of two-element tuples used query argument, first element of each tuple key , second value. value element in can sequence , in case, if optional parameter doseq evaluates true, individual key=value pairs separated '&' generated each element of value sequence key. order of parameters in encoded string match order of parameter tuples in sequence. urlparse module provides functions parse_qs() , parse_qsl() used parse query strings python data structures.
source: python manual
Comments
Post a Comment