(Oct-06-2019, 05:25 AM)scidam Wrote: Take a look at the struct module.
import struct four_bytes = b'abcd' # sample bytesting struct.unpack("I", four_bytes) # interpret bytesting as unsigned int
From what I see the difference is that you used "I" instead my "h". I changed it and didn't change the error message.
(Oct-06-2019, 06:38 AM)Gribouillis Wrote: Are you sure it's this line that causes this error message? If 'header' is a bytes string (which you can check by printing the type of the variable) there should be no problem accessing header[4]
, and it must be an integer. In the worst case it could raise an IndexError.
It says line 11, which is the one that uses struct.unpack. I checked the type and it shows
Quote:<class 'bytes'>