url.encore/quote

Z

zowtar

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?
 
I

ianitux

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?

Hi, a quick solution can be this one, or maybe you can do something
similar
'style=flex%20power&page=i&order=desc'
 
J

John Salerno

zowtar said:
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.
 
I

ianitux

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.
'style%3Dflex%2Bpower%26page%3Di%26order%3Ddesc'
 
J

John Salerno

ianitux said:
This is what quot do.

'style%3Dflex%2Bpower%26page%3Di%26order%3Ddesc'

I know quote will convert spaces to %20, just wasn't sure if it would
explicitly convert + to %20.

But it seems the output isn't what the OP wants anyway, because he wanted
the & and = symbols.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top