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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -