首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在运行其他信息的同时编程时钟

如何在运行其他信息的同时编程时钟
EN

Stack Overflow用户
提问于 2018-05-14 00:46:17
回答 1查看 37关注 0票数 0

我想创建一个游戏,其中的想法是尽可能多的垃圾邮件在时间限制:9.58(它是链接到跑步)。这就是我所得到的。我的问题是,我不确定如何创建时钟,同时计算某些东西的数量/接收输入

代码语言:javascript
复制
 import time
 print("Spamming race")
 print("*************")
 print("Running and spamming have alot in common, like in in running")
 print(" you  want to see how quick you cross the line and in ")    
 print("spamming the aim is to shut down the server as quick as")
 print("possible.")
 max_time =1
 t=31
 start_time = time.time()
 g=input()
 distance=g.count('1')
 if time.time-start_time>max_time>t:
    print("And he crosses the line with a distance of ",distance)

我尝试过用不同的方法来解决这个问题,但是可能有一行代码我不知道哪一行可能会有帮助。

EN

回答 1

Stack Overflow用户

发布于 2018-05-14 01:18:56

代码语言:javascript
复制
from datetime import timedelta,datetime


print("Spamming race")
print("*************")
print("Running and spamming have alot in common, like in in running")
print(" you  want to see how quick you cross the line and in ")
print("spamming the aim is to shut down the server as quick as")
print("possible.")
td = timedelta(seconds=5)
start_time = datetime.now()
distance=0
while(start_time+td>datetime.now()):
    print("check spam")
    g = input()
    distance +=1

print("And he crosses the line with a distance of ", distance)

您可能需要考虑非阻塞输入之类的东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50318415

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档