How to URL Decode a Query String in Python

We can make use of the urllib.parse module to decode a query string using Python.

Example:

from urllib.parse import unquote

url_encoded_query_string = "date=2023/07/23%2011%3A50%20AM&message=Hello%21%20How%20are%20you%3F"
decoded_query_string = unquote(url_encoded_query_string)

print(decoded_query_string)

Output:

date=2023/07/23 11:50 AM&message=Hello! How are you?

URL Decode Python Query String Example

Read More:

https://docs.python.org/3/library/urllib.parse.html

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!