Sending print output to a file in Python script -


this question has answer here:

how go sending output of print command new file? have python script need redirect output @ end of print statement file can't seem find way accomplish redirect. why doesn't "print (stuff redirected) > newfile.txt" work?

any appreciated!

as mentioned in this post, set standard output file object.

import sys sys.stdout = open('file', 'w') 

then, print statements should go directly file.


Comments

Popular posts from this blog

angularjs - Showing an empty as first option in select tag -

qt - Change color of QGraphicsView rubber band -

php - Cloud9 cloud IDE and CakePHP -