#coding:utf-8
import sys
print 'Restore sys.stdout'
print 'should in screen'
import sys
f=open('sys_midware.txt','wr')
#保存输出对象
old_stdout=sys.stdout
#重定向输出
sys.stdout.write("should in file f")
#还原输出
print 'Restore sys.stdout'
print 'should in screen'