例子:


import struct

#open binary file
file=open('./xxx.dat','rb')

num  = 256 #size of file

a = 20 #start position of file

#show byte by byte

for c in range(a,num):
    file.seek(c)
    data=struct.unpack("B",file.read(1))

    print (data[0]) 

python二进制文件转十进制

相关文章: