Python – turtle.bye()
turtle 模块以面向对象和面向过程的方式提供了Turtle图形原语。因为它使用 tkinter 作为底层图形,它需要安装一个支持 Tk 的 Python 版本。
turtle.bye()
该函数用于关闭Turtle图形窗口。它不需要任何参数。
语法: turtle.bye()
参数:无
返回:无
下面是上述方法的实现和一些例子。
示例 1:
# import package
import turtle
# set turtle speed to
# slowest for better
# understandings
turtle.speed(1)
# motion
turtle.forward(200)
# use bye() method to
# shut the window
turtle.bye()
输出 :
例2 :
# import package
import turtle
# set drawing turtle speed
turtle.speed(10)
# loop for pattern
for i in range(12):
turtle.circle(50)
turtle.right(30)
# As simply use of bye() here will shut the
# turtle graphics window too fast so use
# loops to pass the time
for i in range(2000):
for j in range(500):
pass
# shut the turtle graphics window
turtle.bye()
输出 :