Sending print output to a file in Python script -
this question has answer here:
- correct way write line file? 8 answers
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
Post a Comment