SyntaxFix
Write A Post
Hire A Developer
Questions
Redirect sys.stdout to an open file handle and then all printed output goes to a file:
import sys filename = open("outputfile",'w') sys.stdout = filename print "Anything printed will go to the output file"