-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
  • 99,095
  • 21
  • 171
  • 219
ddd
  • 167
  • 1
  • 7

1 Answers1

1

Open the file in append mode

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