If the data is in UTF-8 compatible format, you can convert the bytes to a string.
>>> import curses >>> print(str(curses.version, "utf-8")) 2.2
If desired, first convert to hexadecimal if the data is not yet compatible with UTF-8. For example, when the data is actual raw bytes.
from binascii import hexlify from codecs import encode # alternative >>> print(hexlify(b"\x13\x37")) b'1337' >>> print(str(hexlify(b"\x13\x37"), "utf-8")) 1337 >>>> print(str(encode(b"\x13\x37", "hex"), "utf-8")) 1337
Frank Mar 19 '18 at 10:59 2018-03-19 10:59
source share