Creating a Stopwatch progam for Python 3.3 only in IDLE -
i have assignment need create stopwatch, idle. here's have far, i'm not sure how convert times normal time.
import time start = 0 def stopwatch(): while true: command = input("type: start, stop, reset, or quit: \n") if (command == "quit"): break elif (command == "start"): start = time.time() print(start) stopwatch2() elif (command == "stop"): stopwatch() elif (command == "reset'"): stopwatch() else : break def stopwatch2(): while true: command = input("type: stop, reset, or quit: \n") if (command == "quit"): break elif (command == "stop"): total = time.time() - start print(total) stopwatch() elif (command == "reset'"): stopwatch() else: break stopwatch()
thanks help!
you can use datetime.timedelta()
:
import datetime print(datetime.timedelta(seconds=total))
for example:
in [10]: print datetime.timedelta(seconds=10000000) 115 days, 17:46:40