all Python 3binasciifunction
binascii.b2a_uu()
uuencode and quoted-printable
Encodes up to 45 bytes into one uuencode line with a trailing newline. An old format for sending binary files over email and Usenet.
Syntax
binascii.b2a_uu(data, *, backtick=False)
It handles exactly one line: more than 45 bytes raises binascii.Error 'At most 45 bytes at once', so chunking is up to you. The first character of the line encodes its length. Zeros become spaces by default, which mail software likes to strip; backtick=True (3.7+) writes '`' instead. New code uses base64 instead of uuencode.
Examples
import binascii
print(binascii.b2a_uu(b'hi')) # → b'":&D \n'
print(binascii.b2a_uu(b'\x00\x00\x00', backtick=True)) # → b'#````\n'
try:
binascii.b2a_uu(b'x' * 46)
except binascii.Error as e:
print(e) # → At most 45 bytes at once
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy