struct.error: unpack requires a string argument of length 4
- by Thomas O
Python says I need 4 bytes for a format code of "BH":
struct.error: unpack requires a string argument of length 4
Here is the code, I am putting in 3 bytes as I think is needed:
major, minor = struct.unpack("BH", self.fp.read(3))
"B" = Unsigned char (1 byte) + "H" unsigned short (2 bytes) = 3 bytes (!?)
struct.calcsize("BH") says 4 bytes.