Here's my situation: after running a Python file in VS Code I get a bunch of results in the terminal (in my case, several integers). Now, I want to export what is displayed on the terminal to a txt. file.
I have tried this:
import sys
f = open("out.text", 'w')
sys.stdout = f
print ("out.text", file=f)
f.close()
Basically, I am looking for something like this:
with open('out.txt', 'w') as f:
print('The data I see in the terminal window', file=f)
Now, how do i get this object: 'The data I see in the terminal window'?
P.S. I am very new to programming.