我正在制作一个计时器,当用户点击“空格”并停在“p”时停止显示结束时间。我可以在20分钟的最长时间停下来吗?有什么样如何在20分钟时停止计时器
if time_passed==20:
break
我的代码:
from turtle import*
from datetime import datetime
...
def start():
undo()
global break1, timerint, startime
break1 = 0
startime = datetime.now()
while True:
timerint = datetime.now()-startime
write(timerint,font=("Arial",50))
undo()
if break1 == 1:
break
def stop():
global break1, timerint, startime
timerint=datetime.now()-startime
write(timerint,font=("Arial",50))
break1 = 1
# Turtle placement code removed
onkeypress(start,"space")
onkeypress(stop,"p")
listen()
欢迎来到StackOverflow。请阅读并遵守帮助文档中的发布准则。 [在主题](http://stackoverflow.com/help/on-topic)和[如何提问](http://stackoverflow.com/help/how-to-ask)适用于此处。 StackOverflow不是一个设计,编码,研究或教程服务。有多种Python定时器可供使用;你在研究前的研究中怎么没有找到它们? – Prune
那有什么好玩的? – Xero0