urls.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:jianshu-api 作者: strugglingyouth 项目源码 文件源码
def replace_query_param(url, key, val):
    """
    Given a URL and a key/val pair, set or replace an item in the query
    parameters of the URL, and return the new URL.
    """
    (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
    query_dict = urlparse.parse_qs(query)
    query_dict[key] = [val]
    query = urlparse.urlencode(sorted(list(query_dict.items())), doseq=True)
    return urlparse.urlunsplit((scheme, netloc, path, query, fragment))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号