(s, altchars=None)
return encoded
Encode a byte string using Base64.

    s is the byte string to encode.  Optional altchars must be a byte
    string of length 2 which specifies an alternative alphabet for the
    '+' and '/' characters.  This allows an application to
    e.g. generate url or filesystem safe Base64 strings.

    The encoded byte string is returned.
Encode a byte string using Base64.
Encode a byte string using Base64 .
def b64encode(s, altchars=None):
    """Encode a byte string using Base64.

    s is the byte string to encode.  Optional altchars must be a byte
    string of length 2 which specifies an alternative alphabet for the
    '+' and '/' characters.  This allows an application to
    e.g. generate url or filesystem safe Base64 strings.

    The encoded byte string is returned.
    """
    if not isinstance(s, bytes_types):
        raise TypeError("expected bytes, not %s" % s.__class__.__name__)
    # Strip off the trailing newline
    encoded = binascii.b2a_base64(s)[:-1]
    if altchars is not None:
        if not isinstance(altchars, bytes_types):
            raise TypeError("expected bytes, not %s"
                            % altchars.__class__.__name__)
        assert len(altchars) == 2, repr(altchars)
        return _translate(encoded, {'+': altchars[0:1], '/': altchars[1:2]})
    return encoded
def b64encode ( s , altchars = None ) : if not isinstance ( s , bytes_types ) : raise TypeError ( "expected bytes, not %s" % s . __class__ . __name__ ) # Strip off the trailing newline encoded = binascii . b2a_base64 ( s ) [ : - 1 ] if altchars is not None : if not isinstance ( altchars , bytes_types ) : raise TypeError ( "expected bytes, not %s" % altchars . __class__ . __name__ ) assert len ( altchars ) == 2 , repr ( altchars ) return _translate ( encoded , { '+' : altchars [ 0 : 1 ] , '/' : altchars [ 1 : 2 ] } ) return encoded