Python-turtle示例
一个turtle画图的示例
import turtle
turtle.speed(0)
turtle.penup()
def drawDash(n):
for i in range(0,n):
turtle.pendown()
turtle.forward(10)
turtle.penup()
turtle.forward(10)
def draw(x,y):
turtle.goto(x,y)
turtle.pendown()
drawDash(5)
turtle.left(90)
drawDash(5)
turtle.left(90)
drawDash(5)
turtle.left(90)
drawDash(5)
turtle.left(90)
turtle.penup()
def clear(x,y):
turtle.clear()
turtle.onscreenclick(draw, 1)
turtle.onscreenclick(clear, 3)