In Python, each module has its own namespace. By default, you need to include the module name when calling a method in that module:
import binascii
num = binascii.a2b_base64("04")
print num
Note that a2b_base64 converts a string of Base64-encoded binary data into its raw binary form, which sounds like it's not what you actually want. To convert a string of hexadecimal digits into a string of hex data, use a2b_hex:
>>> import binascii
>>> binascii.a2b_hex("04")
'\x04'
Answer from Tim Pierce on Stack OverflowPython
docs.python.org › 3 › library › binascii.html
binascii — Convert between binary and ASCII
The binascii module contains a number of methods to convert between binary and various ASCII-encoded binary representations. Normally, you will not use these functions directly but use wrapper modules like base64 instead.
Codecademy
codecademy.com › docs › python › binascii module › .hexlify()
Python | Binascii Module | .hexlify() | Codecademy
October 29, 2025 - The .hexlify() method from Python’s binascii module encodes binary data into a hexadecimal (base-16) ASCII representation. It’s an alias for binascii.b2a_hex() and is commonly used to represent binary data in a readable hex format.
Codecademy
codecademy.com › docs › python › binascii module
Python | Binascii Module | Codecademy
October 25, 2023 - The binascii module is a built-in module that provides essential functions for working with binary data and performing binary-to-text encoding and decoding.
Starred by 6 users
Forked by 4 users
Languages: JavaScript
W3Schools
w3schools.com › python › ref_module_binascii.asp
Python binascii Module
The binascii module converts between binary and various ASCII representations (like hex and Base64 helpers).
MicroPython
docs.micropython.org › en › latest › library › binascii.html
binascii – binary/ASCII conversions — MicroPython latest documentation
This module implements a subset of the corresponding CPython module, as described below. For more information, refer to the original CPython documentation: binascii.
Jython
jython.org › jython-old-sites › docs › library › binascii.html
18.13. binascii — Convert between binary and ASCII — Jython v2.5.2 documentation
The binascii module contains a number of methods to convert between binary and various ASCII-encoded binary representations. Normally, you will not use these functions directly but use wrapper modules like uu, base64, or binhex instead.
200ok
200ok.ch › posts › 2018-12-09_unhexlify.html
Python’s binascii – hexlify() and unhexlify()
December 9, 2009 - binascii.unhexlify() naturally does the same thing as hexlify(), but in reverse.
7-Zip Documentation
documentation.help › python-3-7-3 › binascii.html
binascii — Convert between binary and ASCII - Python 3.7.3 Documentation
The binascii module contains a number of methods to convert between binary and various ASCII-encoded binary representations. Normally, you will not use these functions directly but use wrapper modules like uu, base64, or binhex instead.
TutorialsPoint
tutorialspoint.com › python_text_processing › python_conversion_binary_ascii.htm
Python Text Processing - Binary ASCII Conversion
import binascii text = b"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)
Codecademy
codecademy.com › docs › python › binascii module › .b2a_hex()
Python | Binascii Module | .b2a_hex() | Codecademy
October 14, 2025 - Converts binary data to a bytes object containing its hexadecimal (Base16) ASCII representation.
O'Reilly
oreilly.com › library › view › python-standard-library › 0596000960 › ch04s15.html
The binascii Module - Python Standard Library [Book]
May 10, 2001 - File: binascii-example-1.py import binascii text = "hello, mrs teal" data = binascii.b2a_base64(text) text = binascii.a2b_base64(data) print text, "<=>", repr(data) data = binascii.b2a_uu(text) text = binascii.a2b_uu(data) print text, "<=>", repr(data) data = binascii.b2a_hqx(text) text = binascii.a2b_hqx(data)[0] print text, "<=>", repr(data) # 2.0 and newer data = binascii.b2a_hex(text) text = binascii.a2b_hex(data) print text, "<=>", repr(data) hello, mrs teal <=> 'aGVsbG8sIG1ycyB0ZWFs\012' hello, mrs teal <=> '/:&5L;&\\L(&UR<R!T96%L\012' hello, mrs teal <=> 'D\'9XE\'mX)\'ebFb"dC@&X' hello, mrs teal <=> '68656c6c6f2c206d7273207465616c'
Author: Fredrik Lundh
Published: 2001
Pages: 304
Codecademy
codecademy.com › docs › python › binascii module › .b2a_uu()
Python | Binascii Module | .b2a_uu() | Codecademy
May 21, 2024 - Converts binary data into a bytes object containing a string of ASCII characters in UUEncoded format.
Knowledgize
knowledgize.com › en › d › python-standard-library › knowledge › internet-data-handling › binascii
Python Standard Library - binascii - Knowledgize
The binascii module contains a number of methods to convert between binary and various ASCII-encoded binary representations. Normally, you will not use these functions directly but use wrapper modules like uu, base64, or binhex instead.