資源簡介
讀取16進制文件程序(matplotlib)
代碼片段和文件信息
import?sys
import?os
import?matplotlib.pyplot?as?plt
import?numpy?as?np
HexTable?=?{‘0‘:0‘1‘:1‘2‘:2‘3‘:3‘4‘:4‘5‘:5‘6‘:6‘7‘:7‘8‘:8‘9‘:9‘A‘:10‘B‘:11‘C‘:12‘D‘:13‘E‘:14‘F‘:15}
period?=?[0?for?i?in?range(02048)]
fin??=?open(‘1234.hex‘?‘r‘)
i?=?0
for?aLineData?in?fin:
????????DataLen??=?HexTable[aLineData[1]]*16?+?HexTable[aLineData[2]]
????????DataAddr?=?HexTable[aLineData[3]]*16*16*16?+?HexTable[aLineData[4]]*16*16?+?HexTable[aLineData[5]]*16?+?HexTable[aLineData[6]]
????????DataType?=?HexTable[aLineData[7]]*16?+?HexTable[aLineData[8]]
????????DataContent?=?HexTable[aLineData[9]]*16*16*16*16*16*16*16?+?HexTable[aLineData[10]]*16*16*16*1
- 上一篇:python 實現電子計算機
- 下一篇:python battleship 小游戲
評論
共有 條評論