Given a hex value of 0x183C6 I'd like to write out its corresponding byte value using exactly 3 bytes. I know that struct would do this to 4 bytes but my constraints are to 3 bytes.
So
>>> val = 0x183c6
>>> struct.pack('>L', val)
'\x00\x01\x83\xc6'
Is great but I just want:
'\x01\x83\xc6'
I could post process and strip it after the fact, I could break it up and put each individual byte into a bytearray(), or perhaps do some bit shifting but I wonder if there is a easier way of doing it within struct without post processing.