I am writing sensor data to .txt file like this :

with open('sensor_data.txt' , 'a') as f:

Problem is it appends data to the same file, every time I run test. I want it to be like 'sensor_data_1.txt', 'sensor_data_2.txt', 'sensor_data_3.txt' ..... if I run the code three times. Is there any method to do this?

Similar questions and discussions