all Python 3urllib.parsefunction
urllib.parse.quote_plus()
percent-encoding
Percent-encoding for HTML form values and query strings: a space becomes '+', and '/' is encoded as well.
Syntax
urllib.parse.quote_plus(string, safe='', encoding=None, errors=None)
There are two differences from quote(): a space becomes '+' instead of %20, and the default is safe='', so '/' turns into %2F. A literal '+' is encoded as %2B, otherwise it would read as a space. Do not use quote_plus() for a URL path: there '+' is a literal plus, not a space. Decode with unquote_plus(), not unquote().
Examples
from urllib.parse import quote, quote_plus
print(quote_plus('a b/c&d')) # → a+b%2Fc%26d
print(quote('a b/c&d')) # → a%20b/c%26d
print(quote_plus('1+1')) # → 1%2B1
See also
Open in the full glossarydocs.python.orgReport an inaccuracy