Input without stopping program
问题 I am trying to make a countdown timer that prints the time remaining, and when you input something, it prints what you inputted. My problem is I don't want to wait for the input, just keep running the timer. My incorrect code: timer = 100 while True: print(timer) timer -= 1 if input('> '): print('the output of input') You could say I want to have the timer printing the time in the background. 回答1: Here's a function that will timeout if no input is given: import select import sys def timeout