Nov-02-2018, 03:35 AM
Hi i'm facing on an error:
File "MAC_add1+2.py", line 15, in <module>
line = int(line,16)+2
TypeError: int() can't convert non-string with explicit base
Do anyone who why?
if i just put "line = int(line,16)+1" it will be fine, but if i add another line "line = int(line,16)+2", it will pop out an error.
Do anyone know how to solve this issue.
File "MAC_add1+2.py", line 15, in <module>
line = int(line,16)+2
TypeError: int() can't convert non-string with explicit base
Do anyone who why?
if i just put "line = int(line,16)+1" it will be fine, but if i add another line "line = int(line,16)+2", it will pop out an error.
Do anyone know how to solve this issue.
with open('data.txt') as f,open('data_out.txt', 'w') as f_out: for line in f: line = line.strip() f_out.write('{}'.format(line)) line = int(line,16)+1 f_out.write(('\t{}'.format(hex(line).rstrip("L").lstrip("0x") or "0").expandtabs(5).upper())) line = int(line,16)+2 f_out.write(('\t{}'.format(hex(line).rstrip("L").lstrip("0x") or "0").expandtabs(5).upper()))