【发布时间】:2015-10-15 19:29:51
【问题描述】:
我正在用 Python 制作一个类似游戏的 Cookie 点击器,我试图让 while 循环继续运行,以便它检查一秒钟是否已经过去(因此它添加“cookies”),同时仍在查看用户是否正在制作输入(点击“Cookie”)。
每当我尝试此操作时,它都会等待输入,而不是执行其余的循环。
这是我当前代码的样子(当然还有更多):
While True:
console.clear()
cookieText = "You have " + str(cookies) + " cookies"
print cookieText
clicker = raw_input("")
if clicker == "":
cookies += clickerPower
more...
这是我要补充的:
While True:
last = time()
if last == timer:
timer = last
more...
【问题讨论】:
-
能贴出代码吗?
-
您必须共享代码或部分代码或伪代码才能获得相关帮助
-
或许你可以在这里得到答案stackoverflow.com/a/13034175/1330355
标签: python while-loop user-input