werkzeug.url_decode¶
-
werkzeug.
url_decode
(s, charset='utf-8', decode_keys=False, include_empty=True, errors='replace', separator='&', cls=None)[source]¶ Parse a querystring and return it as
MultiDict
. There is a difference in key decoding on different Python versions. On Python 3 keys will always be fully decoded whereas on Python 2, keys will remain bytestrings if they fit into ASCII. On 2.x keys can be forced to be unicode by setting decode_keys to True.If the charset is set to None no unicode decoding will happen and raw bytes will be returned.
Per default a missing value for a key will default to an empty key. If you don’t want that behavior you can set include_empty to False.
Per default encoding errors are ignored. If you want a different behavior you can set errors to
'replace'
or'strict'
. In strict mode a HTTPUnicodeError is raised.Changed in version 0.5: In previous versions ”;” and “&” could be used for url decoding. This changed in 0.5 where only “&” is supported. If you want to use ”;” instead a different separator can be provided.
The cls parameter was added.
Parameters: - s – a string with the query string to decode.
- charset – the charset of the query string. If set to None no unicode decoding will take place.
- decode_keys – Used on Python 2.x to control whether keys should be forced to be unicode objects. If set to True then keys will be unicode in all cases. Otherwise, they remain str if they fit into ASCII.
- include_empty – Set to False if you don’t want empty values to appear in the dict.
- errors – the decoding error behavior.
- separator – the pair separator to be used, defaults to
&
- cls – an optional dict class to use. If this is not specified
or None the default
MultiDict
is used.