Python将异常值保存为txt文件:
f=open('log.txt','w') __console__ = sys.stdout sys.stdout = f print ('1') sys.stdout = __console__ f.close()