ciao a tutti!
ho un problema con struct.unpack e non capisco cosa sto sbagliando...
>>> struct.unpack("i", b'\x03\x00\x00\x00') # OK!
(3,)
>>> struct.unpack("ih", b'\x03\x00\x00\x00\x04\x00') # OK!
(3, 4)
>>> struct.unpack("ihi", b'\x03\x00\x00\x00\x04\x00\x00\x00\x04\x00') #
ARGHHH
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
struct.error: unpack requires a buffer of 12 bytes
Perché mai se ne aspetta 12? Dovrebbero bastare i 10 che ci sono nel buffer!
Mi aspettavo:
>>> struct.unpack("ihi", b'\x03\x00\x00\x00\x04\x00\x00\x00\x04\x00')
(3, 4, 4)
Cosa sto sbagliando?
Marco
_______________________________________________
Python mailing list
[email protected]
https://lists.python.it/mailman/listinfo/python