I guess there is no one right way how you can solve this task.
You can work with binascii.hexlify
You can work with binascii.hexlify
from binascii import hexlify ba = bytearray(b'\xd0\x13t') hexstr = hexlify(ba).decode() # hexlify returns bytes print(hexstr)Another method could be str-formatting:
ba = bytearray(b'\xd0\x13t') hexstr = ''.join(format(integer, 'x') for integer in ba) print(hexstr)For Python 3.6 fans with format string interpolation:
ba = bytearray(b'\xd0\x13t') hexstr = ''.join(f'{integer:x}' for integer in ba) print(hexstr)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!