Hello I'm trying to make a countdown timer with exactly milliseconds and print it to terminal.
input : a float value like (9.200)
output : countdown time for 9 seconds 200 milliseconds
like below site tool https://www.online-stopwatch.com/countdown-timer/
even i could try to print time in milliseconds format but the time is not exactly. Maybe it's a not good question but Is there any way to do it?. Thank you guys so much.
I tried to search about this case but can't match any Below code is what i got from internet but time is not correct and i need a countdown timer a above site had. Thanks
from __future__ import print_function, division
import time , datetime
counter, timestr = 0, ''
print(time.asctime())
t0 = time.time()
try:
while True:
sectime, ff = divmod(counter,1000)
mintime, ss = divmod(sectime,60)
hh, mm = divmod(mintime, 60)
print(''.join('\b' for c in timestr), end='')
timestr='%02i:%02i:%02i.%2s' % (hh, mm, ss, ff)
print(timestr, end='')
time.sleep(.1)
counter += 1
except KeyboardInterrupt:
t0 = time.time() - t0
print('\nCounter seconds: %.1f, time.time seconds: %.1f'
% (counter/10.0, t0 ))