all Python 3urllib.parsefunction
urllib.parse.unquote_plus()
percent-encoding
Like unquote(), but also turns '+' into a space — for HTML form values and query strings.
Syntax
urllib.parse.unquote_plus(string, encoding='utf-8', errors='replace')
It pairs with quote_plus(). Do not apply it to a URL path: there '+' is a literal plus, and 'C++' turns into 'C' followed by two spaces. A literal plus in a form value arrives as %2B and is decoded correctly. parse_qs() and parse_qsl() already call it — do not apply it again.
Examples
from urllib.parse import unquote, unquote_plus
print(unquote_plus('a+b%20c'), '|', unquote('a+b%20c')) # → a b c | a+b c
print(repr(unquote_plus('C++'))) # → 'C '
print(unquote_plus('1%2B1')) # → 1+1
See also
Open in the full glossarydocs.python.orgReport an inaccuracy