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')
标签:tmp,十六进制,file2,int,res,line,txt,十进制 来源: https://blog.csdn.net/zzzmy159/article/details/122453776