Storing and parsing packed binary data in files : Binary File : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Binary File »

 

Storing and parsing packed binary data in files


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



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo File
» Binary File