我试图让一个对象从屏幕顶部开始,一直到底部并离开屏幕,然后重复。我的老师希望我们使用 while 循环,那么我该怎么做呢?
最佳答案
如果您假设 t
是一只 turtle ,help(t)
会为您提供:
...
...
| hideturtle(self)
| Makes the turtle invisible.
|
| Aliases: hideturtle | ht
|
| No argument.
|
| It's a good idea to do this while you're in the
| middle of a complicated drawing, because hiding
| the turtle speeds up the drawing observably.
|
| Example (for a Turtle instance named turtle):
| >>> turtle.hideturtle()
|
| ht = hideturtle(self)
| Makes the turtle invisible.
|
| Aliases: hideturtle | ht
|
| No argument.
|
| It's a good idea to do this while you're in the
| middle of a complicated drawing, because hiding
| the turtle speeds up the drawing observably.
|
| Example (for a Turtle instance named turtle):
| >>> turtle.hideturtle()
...
...
类似地,还有一个 showturtle()
方法。
如果你算一下:
import turtle
import time
t = turtle.Turtle()
win = turtle.Screen()
for i in range(100):
t.fd(100)
t.hideturtle()
time.sleep(1)
t.showturtle()
关于python - 如何使用 while 循环使 python 中的 turtle 对象再次出现和消失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32983304/