In general, I would recommend that you learn the Python struct for this. This is standard with Python, and it should be easy to translate the question specification into a format string suitable for struct.unpack() .
Note that if there is an โinvisibleโ padding between the "around" fields, you will need to figure this out and include it in the unpack() call, or you will read the wrong bits.
Reading the contents of the file in order to unzip something was pretty trivial:
import struct data = open("from_fortran.bin", "rb").read() (eight, N) = struct.unpack("@II", data)
This unpacks the first two fields, assuming that they start from the very beginning of the file (without filling or extraneous data), and also taking into account their own byte order ( @ symbol). I in the format string means "unsigned integer, 32 bits".
unwind Jan 03 '12 at 10:18 2012-01-03 10:18
source share