Source code :
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import binascii
def test():
print(" Method 1 processing ...")
db = b'859859843905894-000-\x34\x33\x32\x31\x30-ABC-abc'
#2 Hexadecimal byte flow 16 Hexadecimal visible string to
dhs = str(binascii.b2a_hex(db), 'utf-8').upper()
print(dhs, type(dhs))
#16 Hexadecimal string to 2 Binary byte stream
db = binascii.a2b_hex(dhs)
print(db, type(db))
# Byte flow utf-8 character string
das = str(db, 'utf-8')
print(das, type(das))
#utf-8 String to byte stream
db = bytes(das, 'utf-8')
print(db, type(db))
print("\n\n Method 2 ...")
db = b'859859843905894-000-\x34\x33\x32\x31\x30-ABC-abc'
print(db, type(db))
das = db.decode('ascii')
print(das, type(das))
dus = db.decode('utf-8')
print(dus, type(dus))
dab = das.encode('ascii')
dub = dus.encode('utf-8')
print(dab, type(dab))
print(dub, type(dub))
if __name__ == '__main__':
print("begin...")
test()
print("end")
Running results :