所以我想在学校解决这个问题。我试着每分钟打印出x,每十分钟打印一行。到目前为止,我不能得到“打印x”每分钟下来。有人能帮忙吗。 这是我的密码
import time;
inTime = float(input("type in how many second"))
oldTime = time.time()-inTime
print (time.time())
def tenMin(oldTime):
newTime = time.time()
if ((newTime - oldTime)>= 25):
return True
else:
False
while (True):
if (tenMin==True):
print ("x")
newTime = time.time()
oldtime = time.time()
else:
oldTime = time.time()
continue
首先,您的代码有一些问题:
else: False
-这在python中不是正确的语法。如果你想要定时器,为什么要请求用户输入?
你有一个逻辑问题:
inTime = float(input("type in how many second"))
oldTime = time.time()-inTime
你知道吗时间。时间float是的,但是用户真的知道在UnixTime中打印什么吗?
我会建议一个简单的解决方案,虽然不是最好的,但确实有效。 每1分钟打印一次“x”,10分钟后打印“\n”(新行)
你的第一个问题是排队
如果将函数引用与布尔值进行比较,那么答案显然是错误的。必须传递一个参数
。。。你知道吗
相关问题 更多 >
编程相关推荐