Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export Python printed output to txt file at the end of code

Tags:

python

I have several thousand lines of code that all ultimately results in a few strings being printed using print() calls. Is there a way to, at the bottom of my code, export everything that has been printed to a text file?

like image 373
JackW24 Avatar asked Dec 21 '25 21:12

JackW24


1 Answers

This will help.

python main.py > output.txt

The operator > redirects the output of main.py from stdout to the regular file output.txt.

like image 129
LEGION GREEN Avatar answered Dec 24 '25 10:12

LEGION GREEN



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!