您的位置:首页 > 编程语言 > Python开发

python二进制文件转十进制

2017-10-21 19:42 204 查看
例子:

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]) 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息