how to add lines to existing file using python

前端 未结 3 1609

I already created a txt file using python with a few lines of text that will be read by a simple program. However, I am having some trouble reopening the file and writing ad

3条回答
  •  独厮守ぢ
    2020-12-03 03:17

    If you want to append to the file, open it with 'a'. If you want to seek through the file to find the place where you should insert the line, use 'r+'. (docs)

提交回复
热议问题