Python Glossary Русский

all Python 3base64term

base64

module

Encoding bytes as Base64, Base32, Base16 and Base85 text and back.

Syntax

import base64

Use it to carry binary data through a text channel: JSON, URLs, email, data URIs. Base64 is not encryption but a reversible representation anyone can read. The functions take and return bytes, so a string is encoded with encode first; for URLs and file names use urlsafe_b64encode.

Examples

import base64
data = base64.b64encode('Привет'.encode())
print(data)  # → b'0J/RgNC40LLQtdGC'
print(base64.b64decode(data).decode())  # → Привет

See also

Open in the full glossarydocs.python.orgReport an inaccuracy