[code.view]

[top] / python / PyMOTW / urllib / urllib_urlencode.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     #end_pymotw_header
     
     import urllib
     
     query_args = { 'q':'query string', 'foo':'bar' }
     encoded_args = urllib.urlencode(query_args)
     print 'Encoded:', encoded_args
     
     url = 'http://localhost:8080/?' + encoded_args
     print urllib.urlopen(url).read()
     

[top] / python / PyMOTW / urllib / urllib_urlencode.py

contact | logmethods.com