
#Python countdown timer update#
The most obvious is time.sleep(0.1) waits 100ms, not 1, so your timer won't ever update that often. The code vou've shared definitely has problems - its a lot for me to completely explain here. Right after I posted this, I saw that you'd updated your question. You might not be able to really do anything about this, that's a problem with the terminal app. In some terminals/GUIs, \r may not actually move the cursor back to the start of the line as expected.See What is the best way to repeatedly execute a function every x seconds? for several better alternatives since accuracy may be important here. This may not be accurate, especially if your print statement is slow in the the terminal.Then use $ python3 timer.py 5 or something like that in your terminal. _TIME = 5 # Just for example, remove this # Create the variable _TIME from sys.argv or wherever, make sure it is a valid float, > 0, etc etc You could try something like this - # Saved as timer.py You haven't mentioned what exactly didn't work for you, but I'll attempt to give a general answer anyway. Print('\nCounter seconds: %.1f, time.time seconds: %.1f' Print(''.join('\b' for c in timestr), end='') Thanks from _future_ import print_function, division I tried to search about this case but can't match anyīelow code is what i got from internet but time is not correct and i need a countdown timer a above site had.

Maybe it's a not good question but Is there any way to do it?.

Output : countdown time for 9 seconds 200 millisecondsĮven i could try to print time in milliseconds format but the time is not exactly. Hello I'm trying to make a countdown timer with exactly milliseconds and print it to terminal.
