【发布时间】:2021-09-21 23:04:33
【问题描述】:
我正在用 python 编写一个程序,它要求程序在后台不断运行,用户可以随时键入以暂停或结束程序。
到目前为止,我只能让程序完全停止并等待用户输入内容。
uInput = ""
counter = 3
while uInput != "password" and counter >= 0:
uInput = input
if uInput != "password":
print("Incorrect Password.", counter, "tries remaining.")
counter -= 1
输入语句完全冻结程序,直到用户按下回车键。在等待用户输入内容时,是否可以让程序运行,例如计时器或只是另一个程序?任何教程或提示都会有所帮助。
【问题讨论】:
-
一次运行 2 个程序 lmao❤️
-
试着看看这个问题的一些答案:stackoverflow.com/questions/292095/…
标签: python-3.x multithreading user-interface input while-loop