i i only want to save specific print result of every execution of code on text file
i try with
if to,from_addr != '0x':
print(To:,From:)
os.system(f'echo {To:} {From:} >> output.txt')
but everytime fail, also I also want that every time a new result appears, a new line is added and not replace the later output
i try with
with open("Output.txt", "w") as text_file:
print(f"To:" "From:" {to} {from_addr}", file=text_file)
fromis a reserved word so I would not use that a variable name. I have a hard time understanding what you are asking. Maybe give us sample input (as text), and expected output? Also, I can't tell if the above is incomplete snippets or if you haven't extract data from input into variables yet.printis not the function to write to a file, you need to used the file pointertext_fileyou defined when using context manager.printcan write to a file if you specifyfile=<handler>as parameter. By default,printuse the stdout handler. =>file: a file-like object (stream); defaults to the current sys.stdout.(documentation)