Sep-01-2020, 03:31 PM
(This post was last modified: Sep-01-2020, 03:32 PM by deanhystad.)
Nice thing about struct.pack and unpack is it is very easy to fix bytesex problems and you can read/write arrays and structures.
Since struct is the common way to communicate with C/C++ it is going to be around as long as Python. And it is well documented.
As for readability, the shift code reads easier than this?
Since struct is the common way to communicate with C/C++ it is going to be around as long as Python. And it is well documented.
As for readability, the shift code reads easier than this?
def header_address(filename): '''Return unsigned int value starting at byte 36 in the file header''' with open(filename, "rb") as file: file.seek(36, 0) return struct.unpack('>I', file.read(4))