fmt = ''.join((fmt[:idx - 1], str(n), before_char, fmt[idx + 1:]))
return struct.unpack(fmt, data)
data = open('data').read()
x = list(unpack('!HLbbs*', data))
x[-1] = binascii.hexlify(x[-1])
print(x)
Python: unpack format characters