Function
email.base64MIME.encode

Signature

encode(s, binary=True, maxlinelen=76, eol='\n')

Documentation String

Encode a string with base64.

Each line will be wrapped at, at most, maxlinelen characters (defaults to 76 characters).

If binary is False, end-of-line characters will be converted to the canonical email end-of-line sequence \r\n. Otherwise they will be left verbatim (this is the default).

Each line of encoded text will end with eol, which defaults to "\n". Set this to " " if you will be using the result of this function directly in an email.