On this page
base64.b64decode
Prev: base64.b32hexencode | Up: base64 | Next: base64.b64encode
Rel: base64.a85decode, base64.a85encode, base64.b16decode, base64.b16encode
Ref: docs.python.org — base64.b64decode
Tags: #public #python3 #stdlib #base64
Import
import base64
from base64 import b64decode
Signature & Overview
base64.b64decode(s, altchars=None, validate=False)
Decode the Base64 encoded bytes-like object or ASCII string s.
Usage
import base64
assert base64.b64decode(b"aGVsbG8=") == b"hello"
assert base64.b64decode("aGVsbG8=", validate=True) == b"hello"
Gotchas
- Pass
validate=Trueon untrusted input: By defaultb64decode()silently discards non-alphabet characters instead of raisingbinascii.Error.
REPL Inspect
from base64 import b64decode
help(b64decode)
Linked from
Related notes
- tuts/python3/stdlib_module/base64 Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/b32hexencode Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/base64/b64encode 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