PyDocs

Nav

Internet Data Handling

b64encode

base64

function (source)
  • b64encode(s, altchars=None, *, padded=True, wrapcol=0)
Encode the bytes-like object s using Base64 and return a bytes object.

Optional altchars should 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.

If padded is false, omit padding in the output.

If wrapcol is non-zero, insert a newline (b'\n') character after at most
every wrapcol characters.
Changed in 3.15
  • 3.15: Added the padded and wrapcol parameters.
1 Example
>>> import base64
>>> encoded = base64.b64encode(b'data to be encoded')
>>> encoded
b'ZGF0YSB0byBiZSBlbmNvZGVk'
>>> data = base64.b64decode(encoded)
>>> data
b'data to be encoded'
from the Python docs
See Also
No see-alsos for base64/b64encode
0 Notes
No notes for b64encode