-1

I use a click program the help of PyGame in Python. I want to use the program multiple times by opening up the program, and shutting it down and reopening it again.

So basically I open the program, click something, and it writes the click time into a .txt file. My problem is, when I shut down the program and run it again, it overwrites the .txt file. So my question is, how to avoid this?

#Pygame program....
f = open("test.txt","w") 
f.write("write something")
sloth
  • 95,484
  • 19
  • 164
  • 210
ddd
  • 133
  • 1
  • 6

1 Answers1

1

Open the file in append mode

f = open('test.txt', 'a')
fstop_22
  • 921
  • 5
  • 9