Published on

How to Remove Query String from URL in Python

Authors

While working on our latest project we needed to remove the query string from a URL. And store it in the database. Here how I did it in Python.

def query_string_remove(url):
    return url[:url.find('?')]

Make sure you are giving valid URL.

Valid - http://www.example.com/?q="Hello"

Invalid - www.example.com/?q="Hello"

Reference