By using binascii module

Binascii helps convert between binary and various ASCII-encoded binary representations.

b2a_uu() function: Here the “uu” stands for “UNIX-to-UNIX encoding” which takes care of the data conversion from strings to binary and ASCII values according to the specified program.

The b2a_uu() function is used to convert the specified binary string to its corresponding ASCII equivalent.

Syntax: b2a_uu(Text)

Parameter: This function accepts a single parameter which is illustrated below:

  • Text: This is the specified binary string that is going to be converted into its ASCII equivalent.

Return Values: This function returns the ASCII equivalent.

Example: Convert binary to ASCII.

Python3




# Python program to illustrate the
# conversion of Binary to ASCII
 
# Importing binascii module
import binascii
 
# Initializing a binary string
Text = b"GFG is a CS Portal"
 
# Calling the b2a_uu() function to
# Convert the binary string to ascii
Ascii = binascii.b2a_uu(Text)
 
# Getting the ASCII equivalent
print(Ascii)


Output:

b"21T9'(&ES(&$@0U,@4&]R=&%L\n"

Python program to convert binary to ASCII

In this article, we are going to see the conversion of Binary to ASCII in the Python programming language. There are multiple approaches by which this conversion can be performed that are illustrated below:

Similar Reads

Method 1: By using binascii module

Binascii helps convert between binary and various ASCII-encoded binary representations....

Method 2: Using Built-in Types.

...

Method 3 : Using chr() and join() methods

Here we will use a built-in type to convert binary to ASCII value....