1

I have a python script_1 which will be used to call another python script_2 using subprocess. When I do that I can see so many print statements and ouputs on the python console (or cmd). How can I redirect this output to a file along with displaying the output on the python console.

Basically, I need a windows executable command for ' | & tee ' command of Linux. I tried many methods and all those didn't work.

Thanks for the help. :)

4
  • Please share your code. Commented Jul 4, 2018 at 8:59
  • 1
    Pure python solution: use the logging package with two handlers (one logging to stderr and one logging to file). Commented Jul 4, 2018 at 9:00
  • 2
    Possible duplicate of Python Popen: Write to stdout AND log file simultaneously Commented Jul 4, 2018 at 9:00
  • The easiest way in cmd might be {your python command line} > file.log & type file.log, although this will display the text only after your scripts have finished execution, of course... Commented Jul 4, 2018 at 12:01

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.