What is binascii.b2a_uu in Python?

The binascii is a widely used Python library for ASCII-encoded binary representations. It contains several methods to convert to binary from ASCII or hex, and vice versa. Most methods are not used directly, but wrapper modules such as uu, base64, or binhex are commonly used.

binascii.b2a_uu is one of the many wrapper modules in the binascii library. It is used to convert data (in binary) to a line of ASCII characters. This means the ASCII characters are returned as a single line with a “\n” character at the end to indicate to new line character.

Syntax

binascii.b2a_uu(data, *, backtick=False)

Parameters

  1. data: The data that needs to be converted. The length of returned line should be 45 at most.

  2. backtick: This is used if a user wishes to replace the zeros with a ‘`’.

import binascii
text = "HeLLo WorLd"
text = bytes(text , 'utf-8')
data = binascii.b2a_uu(text)
text = binascii.a2b_uu(data)
print(str(text), "<=>", str(data))
Copyright ©2024 Educative, Inc. All rights reserved