Friday, August 30, 2019

Python: redirect output to a file


To redirect the standard output to a file by the source code, add this in the beginning of the Python script:

import sys
sys.stdout = open('/path/to/outputfile', 'a')

No comments:

 
Get This <