Python binary to ASCII conversion
Python Binary to ASCII
ASCII-to-binary and binary-to-ASCII conversions are performed by the built-in binascii module. It features intuitive functions for converting input data. The following program demonstrates the use of the binascii module and its functions b2a_uu and a2b_uu . “uu” stands for “UNIX to UNIX encoding” and is responsible for converting strings into the binary and ASCII values required by the program.
import binascii
text = "Simply Easy Learning"
# Converting binary to ascii
data_b2a = binascii.b2a_uu(text)
print "**Binary to Ascii** n"
print data_b2a
# Converting back from ascii to binary
data_a2b = binascii.a2b_uu(data_b2a)
print "**Ascii to Binary** n"
print data_a2b
When we run the above program, we get the following output –
**Binary to Ascii**
44VEM&QY($5AWD@3&5AFYI;F
**Ascii to Binary**
Simply Easy Learning