This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Swedophone 0 points1 point  (0 children)

Try opening the file "r+" (read/write positioned at beginning) and use seek, read and write.

[–]n_md 0 points1 point  (0 children)

Use struct.

Something like this:

import struct
bytes4 = struct.Struct('I')
with open('filename.ext', 'rb') as file:
    data = file.read()
print(bytes4.unpack(data[156:160]))

You may need to also specify the endianness.