util.py 文件源码

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

项目:djangoblog 作者: liuhuipy 项目源码 文件源码
def unquote(s):
    """
    Undo the effects of quote(). Based heavily on urllib.unquote().
    """
    cls_str = str if six.PY3 else basestring
    if not isinstance(s, cls_str):
        return s
    mychr = chr
    myatoi = int
    list = s.split('_')
    res = [list[0]]
    myappend = res.append
    del list[0]
    for item in list:
        if item[1:2]:
            try:
                myappend(mychr(myatoi(item[:2], 16)) + item[2:])
            except ValueError:
                myappend('_' + item)
        else:
            myappend('_' + item)
    return "".join(res)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号