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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would not even approach this from a python-fix perspective, but simply redirect the output of running your python script:
Nothing has to change in your script, and all print statements will end up in your text file.