目的是将print的结果输出到一个文件中,比如这个文件在D:\lianxi\out.txt下,我用的windows:

s = '1234'

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

print (s,file = f)

然后f.close()

网上也有说直接print(s,f),也就是不用file = f, 但是我试了一下好像不行啊

 

相关文章:

  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-15
  • 2021-06-05
  • 2021-10-21
  • 2021-10-22
  • 2022-12-23
  • 2021-09-13
相关资源
相似解决方案