Use batch to redirect prints into a file

Solution 1:

you have 2 ways to do it:

  1. in cmd -> python script.py > log.txt

  2. in your python code:

example:

import sys
sys.stdout = open(PATH_TO_LOG_FILE, "w")
print("hello world")
sys.stdout.close()

output: hello world (in log text file)