I want to make a timer which requiers space press to stop it. I also want to print out how much time has passed since the start of the loop. I tried this:
import msvcrt
import time
print("Press space")
start_time = time.time()
while True:
# print how much time has passed
print(start_time - time.time(), end='\r')
# break the loop if space btn was pressed
if msvcrt.getch() == b" ":
break
But the problem is that the time passed will be printed only if I pressed a key, and I want it to print out continuesly. I tried this solution from https://stackoverflow.com/a/22391379/12132452, but because it was python 2, i kept getting this error
Traceback (most recent call last):
File "f:/Projects/Python/test.py", line 9, in <module>
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
OSError: [WinError 10093] Either the application has not called WSAStartup, or WSAStartup failed
What do I need to do?