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)
评论列表
文章目录