我的理解:默认情况下,编译器的输出sys.stdout默认是输出在底下的框里,如果要保存在文件中,方便随时查看就需要一下操作:
import sys
temp=sys.stdout#将原输出路径保存
sys.stdout=open(r".\log_test.txt", 'a')#输出到路径中的文件
print("where is it?")#输出到文件中
sys.stdout=temp#输出回原路径,即底下的框中
print("now, where?")#输出到底下的框中
print("it's a fake wrong", file=sys.stderr)#报错信息同样如此,将print的内容输出到默认的报错路径中
输出: