import sys
import pdb
fileName = 'test.hex'
def hextobytesfromfile():
with open(fileName, 'r') as fileIn:
for lineHex in fileIn:
print(lineHex)
#print(len(lineHex))
#pdb.set_trace()
if lineHex[-1] is '\n':
lineBytes = bytes.fromhex(lineHex[1:-1]) #bytearray
else:
lineBytes = bytes.fromhex(lineHex[1:]) #last line
#print(lineBytes)
print(list(lineBytes))
print(lineBytes.hex())
if __name__ == '__main__':
hextobytesfromfile()
阅读(542) | 评论(0) | 转发(0) |