txt文件从十六进制到十进制

filename = "out.txt"

res=[]
with open(filename) as file:
    lines=file.readlines()
    for line in lines:
        tmp=''
        line=line.strip('\n')
        for i in range(int(len(line)/4)):
            t16=line[i*4:(i+1)*4]
            t10=int(t16,16)
            tmp+=str(t10)+' '
        res.append(tmp[:-1])

with open("result.txt",'w') as file2:
    for newline in res:
        file2.write(newline)
        file2.write('\n')
上一篇:Day 4 Queue


下一篇:Cache Memory技术示例