On this page
base64.b64encode
Prev: base64.b64decode | Up: base64 | Next: base64.b85decode
Rel: base64.a85decode, base64.a85encode, base64.b16decode, base64.b16encode
Ref: docs.python.org — base64.b64encode
Tags: #public #python3 #stdlib #base64
Import
import base64
from base64 import b64encode
Signature & Overview
base64.b64encode(s, altchars=None)
Encode the bytes-like object s using Base64 and return a bytes object.
Usage
import base64
assert base64.b64encode(b"hello") == b"aGVsbG8="
Gotchas
- Takes
bytes, returnsbytes: Encodestrfirst (.encode("utf-8")) and call.decode("ascii")if you need a JSON-safe string.
REPL Inspect
from base64 import b64encode
help(b64encode)
Linked from
Related notes
- tuts/python3/stdlib_module/base64 Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/b64decode Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/b85decode Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/a85decode Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/a85encode Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/b16decode Linked here; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/b16encode Linked here; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib