The below code is reading a file called ‘test.txt’ which has hex numbers. The below code is converting these hex number into decimal numbers. How can I write the decimal number to a file instead of printing it out?
my code
file= 'test.txt'
with open(file) as fp:
   line = fp.readline()
   cnt = 1
   while line:
       i = int(line, 16)
       print(str(i))
       line = fp.readline()
       cnt += 1
 
     
     
    