Avatar ·

How to write in Stdout and a file at the same time?

📁 Advanced Python Topics, question

There is a Python script:

   import  sys sys.stdout =  open  ( 'my_log.log' ,  'w' )   print   'test'    

It writes the entire standard output to the file. Question: How can I write to the file and at the same time display to the console?