#!/usr/bin/python # Run a timer and save it to a file import time from datetime import timedelta count = 0 while True: # Code executed here time.sleep(1) count += 1 elapsedTime = timedelta(seconds=count) # convert integer into hh:mm:ss format lineout = "{\"clock\":\"" + str(elapsedTime) + "\"}" # write message to file text_file = open("sim_clock.json", "w") text_file.write(lineout) text_file.close() print count