Jun-13-2020, 05:28 PM
(This post was last modified: Jun-13-2020, 05:28 PM by DreamingInsanity.)
On the line that's erroring (line 9), you are using struct.unpack. You are passing in "bytearray". In python bytearray is a type that an object can be.
It seems you want to unpack the header of the file. In that case you would want to read the file into a byte array and pass that in instead.
This should work:
You may need that, you may not.
It seems you want to unpack the header of the file. In that case you would want to read the file into a byte array and pass that in instead.
This should work:
b_array = bytearray(f.read()) _ignored, n_images, image_columns, image_rows = struct.unpack('>IIII', b_array)EDIT: I did a quick test. For me, running that code gave me an error saying it wanted a 16 byte buffer. I had to do this instead:
_ignored, n_images, image_columns, image_rows = struct.unpack('>IIII', bytearray(a.read()[:16]))
You may need that, you may not.