有没有什么方法可以在打印标准输出的同时打印到文本文件?例如:打印标准输出,同时也打印到Python中的文本文件
import sys
sys.stdout = open('file.txt', 'w')
#The stuff below should be printed out and at the same time being printed to a text file
print "This is in a text file and stdout"
所以,再次,有没有办法做到这一点?或者不能这样做?
'tee' - http://stackoverflow.com/questions/616645/how-doi-i- python – Scott
你需要一个多平台解决方案吗? – Matt