url.encore/quote

ianitux ianklaric at gmail.com
Thu Jun 26 16:18:01 EDT 2008


On 26 jun, 15:53, "John Salerno" <johnj... at NOSPAMgmail.com> wrote:
> "zowtar" <zow... at gmail.com> wrote in message
>
> news:889c0e25-c1e0-415b-b6db-f9e633a7eabb at d45g2000hsc.googlegroups.com...
>
> > urlencode({'page': i, 'order': 'desc', 'style': 'flex power'})
> > return:
> > page=1&order=desc&style=flex+power
>
> > but I want:
> > page=1&order=desc&style=flex%20power
>
> > and url.quote don't put the &'s and ='s
> > any idea guys?
>
> urlencode() uses quote_plus() when it creates a URL, which is why you are
> getting the plus signs. Unfortunately I don't have Python at work, so I
> can't try this, but maybe do:
>
> quote(urlencode({'page': i, 'order': 'desc', 'style': 'flex power'}))
>
> and see if that works? I'm not sure if quote() will convert the %20 into +,
> though, but it may.

This is what quot do.

>>> import urllib
>>> u = urllib
>>> u.quote(u.urlencode({'page': 'i', 'order': 'desc', 'style': 'flex power'}))
'style%3Dflex%2Bpower%26page%3Di%26order%3Ddesc'



More information about the Python-list mailing list