How can I use struct.unpack() or some other function available in Python to easily convert one byte variable to a Python integer? Right now, it is done in a rather lame way:
file = open("telemetry.dat", "rb").read()
magic = file[0]
int(binascii.hexlify(magic), 16)
Is there another?
how about
ord(my_byte)?Or if the variable content is like
my_byte == "0xff"orffyou can simply do
int(my_byte, 16)If you have a streamof hex digits, you can do: