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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright ยฉ Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap