Python urlparse.parse_qs unicode url Python urlparse.parse_qs unicode url python python

Python urlparse.parse_qs unicode url


Encode back to bytes before passing it to .parse_qs(), using ASCII:

query_dict = urlparse.parse_qs(query.encode('ASCII'))

This does the same thing as str() but with an explicit encoding. Yes, this is safe, the URL encoding uses ASCII codepoints only.

parse_qs was handed a Unicode value, so it returned you a unicode value too; it is not it's job to decode bytes.