How to output to the console and file?

前端 未结 8 1208
青春惊慌失措
青春惊慌失措 2020-11-30 02:54

I\'m trying to find out a way in python to redirect the script execution log to a file as well as stdout in a pythonic way. Is there any easy way of achieving t

8条回答
  •  盖世英雄少女心
    2020-11-30 03:38

    You should use the logging library, which has this capability built in. You simply add handlers to a logger to determine where to send the output.

提交回复
热议问题