How to write to CSV and not overwrite past text

前端 未结 3 975
不思量自难忘°
不思量自难忘° 2020-12-06 12:31

The code below is what I have so far. When it writes to the .csv it overwrites what I had previously written in the file.How can I write to the file in such a way that it do

3条回答
  •  旧巷少年郎
    2020-12-06 12:51

    change open("learner.csv", "w") to open("learner.csv", "a")

    The second parameter with open is the mode, w is write, a is append. With append it automatically seeks to the end of the file.

提交回复
热议问题