def encode(to_encode):
"""
Encode an arbitrary string as a base64 that is safe to put as a URL query value.
urllib.quote and urllib.quote_plus do not have any effect on the
result of querystringsafe_base64.encode.
:param (str, bytes) to_encode:
:rtype: str
:return: a string that is safe to put as a value in an URL query
string - like base64, except characters ['+', '/', '='] are
replaced with ['-', '_', '.'] consequently
"""
encoded = urlsafe_b64encode(to_encode).replace(b'=', b'.')
if PY2:
return encoded
return encoded.decode()
querystringsafe_base64.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录