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])
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读取二进制文件以及二进制、十进制、16进制间的转化
- [MTK FP]用Python把二进制音频/图片文件转为数组
- python脚本将ascii码形式的文件转换为真正的二进制文件
- python使用B2M算法对二进制文件转灰度图
- Python 二进制文件读取显示 .
- python-17-如何读取文本文件?如何处理二进制文件?如何设置文件的缓冲?
- Python 进制互相转换(二进制、十进制和十六进制)
- Python 二进制/十进制等转换
- python读写文件(读字节,二进制,分行读,追加等)
- python十进制和二进制的转换方法(含浮点数)
- 文件存入oracle数据库 LONG型 二进制 十进制
- Python进制互相转换(二进制、十进制和十六进制)
- Python 3.2 常用代码片段之-十进制转化为二进制
- [Python]sqlite3二进制文件存储问题(BLOB)(You must not use 8-bit bytestrings unless you use a text_factory...)
- 二进制文件转换为十进制文件
- Windows二进制文件的Python扩展包
- 使用Python进行二进制文件读写的简单方法(推荐)
- Python中不同进制互相转换(二进制、八进制、十进制和十六进制)
- Python从二进制文件中提取Exponent和Modulus数据(e, n)并构建公钥
- python将二进制转换为十进制