test = struct.unpack('>%dH' % 1, '\x00\x44')
Is confusing me. I thought it means take the first 8 bytes and treat them as a double then take the next two and treat them as a short, and do all of that one time. But it means something else and I can't figure out what. It seems to realize that there is no double present and converts those two bytes to one number.
This code
test = struct.unpack('>1dH' , '\x00\x44')
Throws an error because it's expecting to find a double...
Can anyone tell me what the difference between these two are?
Thanks
1 Answer 1
'>%dH' % 1 is equivalent to '>1H'.
>>> '>%dH' % 1
'>1H'
'>%dH' % 1 is using old-style string formatting to replace the %d with 1.
So the struct format is specifying a big-endian two-byte unsigned short.