python读取dat文件时遇到16进制转化成10进制问题

读取一定数量的文件内容

str = '\xff\xff\x01\x01\xfd\xff\x03\x01\xfd\x01'

#转化成16进制

import binascii

hexS = map(binascii.b2a_hex,str)

#map函数批量转化成整型,不用列表推导式

data = map(lambda a:int(a,16),hexS)

结果

data=[255, 255, 1, 1, 253, 255, 3, 1, 253, 1]


猜你喜欢

转载自blog.csdn.net/u013516331/article/details/52133505
今日推荐