How to Remove Query String from URL in Python

April 23, 2016

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 -“Hello

Invalid -“Hello”


👋 I'm Ashik Nesin • Principal Software Engineer @Chargebee 👨‍💻• I write about web development & behinds the scenes of startup/side projects that I'm building

© 2022 Nesin Technologies LLP