【发布时间】:2014-04-10 15:24:43
【问题描述】:
有时我希望我的程序在终端上写一些东西以便立即检查,并在一个文件上写一些东西供以后使用,所以我写了这样的东西:
print "output"
file.write("output") #the same output as the previous line
是否有可能使用 python 2.6 或 7 以另一种可能更智能的方式进行操作?
【问题讨论】:
-
你是在问是否有一个函数可以一次输出到文件和终端?
-
print "output"更像是file.write("output"+"\n")...print添加一个尾随换行符。请注意,只是一个细节。
标签: python file terminal output