i figure it out, but it's the format is not good
Out put is
old file new file
0xb
11 0xc
12
i wish to be like this
old file new file
11 0xb
12 0xc
Sorry i solved it. Any comment with the code, that can be written better ?
Out put is
old file new file
0xb
11 0xc
12
i wish to be like this
old file new file
11 0xb
12 0xc
with open('data.txt') as f,open('data_out.txt', 'w') as f_out: f_out.write('old file \t new file \n') #print ('old file \t new file \n') for line in f: line = line.strip() f_out.write(('\t{}\n'.format(hex(int(line)))).expandtabs(18)) #print(('\t{}\n'.format(hex(int(line)))).expandtabs(18)) #f.write('{}\n'.format(hex(int(line)))) f_out.write('{}'.format(line))
Sorry i solved it. Any comment with the code, that can be written better ?
with open('data.txt') as f,open('data_out.txt', 'w') as f_out: f_out.write('old file \t new file \n') #print ('old file \t new file \n') for line in f: line = line.strip() f_out.write('{}'.format(line)) f_out.write(('\t{}\n'.format(hex(int(line)))).expandtabs(18)) #print(('\t{}\n'.format(hex(int(line)))).expandtabs(18)) #f.write('{}\n'.format(hex(int(line))))