目标:将print的结果输出到文件中,比如文件在D:\out.txt:
s = 'hello all'
f = open (r'D:\hello.txt','w')
print (s,file = f)
f.close()