Python 使相位消失

Python 使相位消失,python,python-turtle,Python,Python Turtle,我正在用python制作一个乒乓球游戏,我正在尝试让文本显示几秒钟,然后消失,有人能帮我做这个吗: Instructions.speed(0) Instructions.color("green") Instructions.penup() Instructions.hideturtle() Instructions.goto(0, -260) Instructions.color("red") Instructions.write("W,A a

我正在用python制作一个乒乓球游戏,我正在尝试让文本显示几秒钟,然后消失,有人能帮我做这个吗:

Instructions.speed(0)
Instructions.color("green")
Instructions.penup()
Instructions.hideturtle()
Instructions.goto(0, -260)
Instructions.color("red")
Instructions.write("W,A and arrow keys to move", align="center", font=("Courier", 36, "normal"))

我还需要添加什么?

在写入文本后,我们可以启动screen
ontimer
事件来调用海龟的
clear()
方法来擦除文本。例如:

from turtle import Screen, Turtle

screen = Screen()

turtle = Turtle()
turtle.hideturtle()
turtle.color('red')
turtle.penup()
turtle.sety(-260)

turtle.write("W,A and arrow keys to move", align='center', font=('Courier', 36, 'normal'))
screen.ontimer(turtle.clear, 2000)  # milliseconds in the future

screen.mainloop()

试着做一个简单的break语句。或者,您可以在指令的顶部绘制或更新背景。您可以导入时间库,尝试time.sleep(秒),然后执行turtle.clear()。