读取一定数量的文件内容
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]
读取一定数量的文件内容
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]