If I do
url = "http://example.com?p=" + urllib.quote(query)
- It doesn't encode
/
to%2F
(breaks OAuth normalization) - It doesn't handle Unicode (it throws an exception)
Is there a better library?
|
From the docs:
That means passing '' for safe will solve your first issue:
About the second issue, there is a bug report about it here. Apparently it was fixed in python 3. You can workaround it by encoding as utf8 like this:
By the way have a look at urlencode |
|||||||||||||
|
In Python 3,
|
|||
|
My answer is similar to Paolo's answer. I think module
|
|||||||||
|
If you're using django, you can use urlquote:
|
|||
|