Directing print output to a .txt file

后端 未结 7 2435
北荒
北荒 2020-11-27 13:03

Is there a way to save all of the print output to a txt file in python? Lets say I have the these two lines in my code and I want to save the print output to a file named

相关标签:
7条回答
  • 2020-11-27 13:32

    One can directly store the returned output of a function in a file.

    print(output statement, file=open("filename", "a"))
    
    0 讨论(0)
提交回复
热议问题