How to duplicate sys.stdout to a log file?

前端 未结 17 924
醉酒成梦
醉酒成梦 2020-11-22 06:54

Edit: Since it appears that there\'s either no solution, or I\'m doing something so non-standard that nobody knows - I\'ll revise my question to also ask: What is the best w

17条回答
  •  灰色年华
    2020-11-22 07:38

    I wrote a tee() implementation in Python that should work for most cases, and it works on Windows also.

    https://github.com/pycontribs/tendo

    Also, you can use it in combination with logging module from Python if you want.

提交回复
热议问题