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

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

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

php - Cloud9 cloud IDE and CakePHP -