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) is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. 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 2023 | Privacy Policy | About Us | Contact Us | Sitemap