File Python Tutorial

F = open('data.bin', 'wb')
import struct 
bytes = struct.pack('>i4sh', 7, 'spam', 8)
print bytes 
F.write(bytes)                            
F.close(  ) 
F = open('data.bin', 'rb') 
data = F.read(  )                         
print data 
values = struct.unpack('>i4sh', data)     
print values