On this page
base64.encode
Prev: base64.decodebytes | Up: base64 | Next: base64.encodebytes
Rel: base64.a85decode, base64.a85encode, base64.b16decode, base64.b16encode
Ref: docs.python.org — base64.encode
Tags: #public #python3 #stdlib #base64
Import
import base64
from base64 import encode
Signature & Overview
base64.encode(input, output)
Encode a file; input and output are binary files.
Usage
import base64
import io
inp = io.BytesIO(b"hello")
out = io.BytesIO()
base64.encode(inp, out)
assert out.getvalue() == b"aGVsbG8=\n"
Gotchas
- Inserts
\nevery 76 chars: Useb64encode()for single-line tokens and JSON fields.
REPL Inspect
from base64 import encode
help(encode)
Linked from
Related notes
- tuts/python3/stdlib_module/base64 Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/decodebytes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/encodebytes 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