Sometimes, we want to urlencode a querystring in Python.
In this article, we’ll look at how to urlencode a querystring in Python.
How to urlencode a querystring in Python?
To urlencode a querystring in Python, we can use the urllib.parse.quote_plus
method.
For instance, we wite
import urllib.parse
safe_string = urllib.parse.quote_plus('string_of_characters_like_these:$#@=?%^Q^$')
to call quote_plus
with a string that we want to urlencode.
Conclusion
To urlencode a querystring in Python, we can use the urllib.parse.quote_plus
method.