def update_url(url, query_update, fragment = ''):
    
    url = urlparse.urlparse(url)
    query = urlparse.parse_qs(url.query)
    for key, value in query_update.items():
        if value is None:
            query.pop(key, None)
        else:
            query[key] = value
    fragment = url[5] if fragment == '' else fragment
    return urlparse.urlunparse(url[:4] + (urllib.urlencode(query), fragment))
Replaces query parameters with those given in query_update, and updates the fragment.
dataset/ETHPy150Open mollyproject/mollyproject/molly/utils/http.py/update_url