如何在不等待用户输入的情况下继续程序? 我希望循环在2秒后继续,即使没有用户输入,如果用户类型退出就中断。这段代码不工作,因为我每次都需要手动按enter键才能继续循环。在
while True:
answer = input("please enter quit to stop the program")
time.sleep(2) # wait for 2 seconds for the possible user input "quit"
if answer == "quit":
break
... other code
操作系统:Windows7、Python3.6
我读过:Python: wait for user input, and if no input after 10 minutes, continue with program 和:raw_input and timeout。 我试过窗户的答案,但没有一个奏效。我也不完全理解他们。 请您对代码中的主要步骤发表意见好吗?非常感谢你!在
目前没有回答
相关问题 更多 >
编程相关推荐