python将print结果写到文件中

目标:将print的结果输出到文件中,比如文件在D:\out.txt:

s = 'hello all'

f = open (r'D:\hello.txt','w')

print (s,file = f)

f.close()

猜你喜欢

转载自blog.csdn.net/weixin_41770169/article/details/90053602