【发布时间】:2019-04-06 13:27:23
【问题描述】:
我有一个简单的海龟比赛脚本,我希望比赛在用户单击鼠标左键时开始,所以我有这个代码
def tur_race():
for step in range(0, 135):
tur1.forward(randint(1, 5))
tur2.forward(randint(1, 5))
turtle.pu()
turtle.goto(-250, -150)
turtle.write("click the mouse to start")
turtle.ht()
turtle.onscreenclick(tur_race())
turtle.mainloop()
假设我已经定义了所有变量。
当我运行此代码时,比赛会自动开始,无需等待点击。
【问题讨论】:
-
turtle.onscreenclick( tur_race )在tur_race之后没有() -
@furas 你可以添加这个作为答案。不能吗?