Sep-02-2020, 05:39 AM
Those aren't ints. You describe the bit at the end as "concatenated 8-bit bytes", but I'm guessing they're actually hexadecimal strings, so each character represents a 4-bit value.
You can create a byte object directly from a hex string like this:
You can create a byte object directly from a hex string like this:
>>> nmbr = bytes.fromhex("0102030405") >>> nmbr b'\x01\x02\x03\x04\x05' >>> len(nmbr) 5Since you've opened the file as binary and you have a bytes object, you can write it directly. There's no encoding necessary here.