How to export all print to a .txt file in Python?
export, python, text
Solution
I would not even approach this from a python-fix perspective, but simply redirect the output of running your python script:
python /path/to/script/myscript.py > /path/to/output/myfile.txt
Nothing has to change in your script, and all print statements will end up in your text file.
Problem
Possible Duplicate: Redirect stdout to a file in Python? I've finally finished all the code for my project. Now I need all of the things that are labelled "print" to actually be exported into a .txt document. How would I go about doing that?