import binascii
def hex_to_ascii(hex_str):
hex_str = hex_str.replace(' ', '').replace('0x', '').replace(' ', '').replace('
', '')
ascii_str = binascii.unhexlify(hex_str.encode())
return ascii_str
hex_input = '54 68 69 73 20 69 73 20 61 6e 20 65 78 61 6d 70 6c 65 2e'
ascii_output = hex_to_ascii(hex_input)
print('ascii result is:{0}'.format(ascii_output))
-------------------
ascii result is:b'This is an example.'