Python 标准输出 sys.stdout 重定向,将屏幕输出内容输出到文件

来源:互联网 发布:网络投资平台有哪些 编辑:程序博客网 时间:2024/05/01 10:56

参考:https://www.cnblogs.com/turtle-fly/p/3280519.html


__console__=sys.stdout# redirection start
f_handler=open('out.log', 'w')sys.stdout=f_handlerprint 'hello' 
# redirection endsys.stdout=__console__

阅读全文
0 0
原创粉丝点击