querystringsafe_base64.py 文件源码

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

项目:querystringsafe_base64 作者: ClearcodeHQ 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号