Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import struct
- thefile = open('somebinfile', 'r+b')
- record_size = struct.calcsize(format_string)
- thefile.seek(record_size * record_number)
- buffer = thefile.read(record_size)
- fields = list(struct.unpack(format_string, buffer))
- # Perform computations, suitably modifying fields, then:
- buffer = struct.pack(format_string, *fields)
- thefile.seek(record_size * record_number)
- thefile.write(buffer)
- thefile.close( )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement