urllib2: problem of handling space in parameter

Muddy Coder cosmo_general at yahoo.com
Sat Feb 7 08:47:27 EST 2009

Hi Folks,

I encrountered a problem of using urllib2: the space handling. Look at
the code below:

import urllib2
url = r'http://somedomain.com/a.cgi?name=muddy coder&password=foobar
cgi_back = urllib2.urlopen(url).read()

In this cgi_back, I saw field password worked fine, but field name
not, only muddy was picked up by CGI. So, I had to cover the space, by
using syntax name=muddy-coder, it went through. So, I presume urllib2
may have an approach of handling white space in this regard. Can
anybody help? Thanks!

Muddy Coder

More information about the Python-list mailing list