Python - Only last line is saved to file

后端 未结 4 577
我寻月下人不归
我寻月下人不归 2020-12-02 01:18

I\'m trying to output the result of my script into a text file. The script is working fine, the only problem is when results are saved into the text file (output.txt), only

4条回答
  •  心在旅途
    2020-12-02 01:54

    Did you try with parameter 'a' So: f = open("output.txt", "a")

    That will open the file with pointer at the end. http://www.pythonforbeginners.com/files/reading-and-writing-files-in-python

提交回复
热议问题