util.py 文件源码

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

项目:dream_blog 作者: fanlion 项目源码 文件源码
def quote(s):
    """
    Ensure that primary key values do not confuse the admin URLs by escaping
    any '/', '_' and ':' characters. Similar to urllib.quote, except that the
    quoting is slightly different so that it doesn't get automatically
    unquoted by the Web browser.
    """
    cls_str = str if six.PY3 else basestring
    if not isinstance(s, cls_str):
        return s
    res = list(s)
    for i in range(len(res)):
        c = res[i]
        if c in """:/_#?;@&=+$,"<>%\\""":
            res[i] = '_%02X' % ord(c)
    return ''.join(res)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号