‘’’
初始化屏幕
Windows = turtle.screen()
新建turtle对象实例
import turtle
t=turtle.Turtle()
海龟设置
t.hideturtle()
设置笔的速度
t.speed()
前进后退 左转右转
t.forward(100) fd #前进100像素
t.back(100) bk backward#后退100像素
t.left(90) #左转90°
t.right(90) #右转90°
t.goto(100,100) 将机器小乌龟定位到(100,100)
t.setx(200) 机器小乌龟到x=200,y不变
t.sety(-50) 机器小乌龟到y=-50.x不变
t.setheading(0)
t.seth(90)
机器小乌龟箭头方向调整,0 向右,90,向上,180 向左,270,向下
t.circle(100) 逆时针画圆,10像素半径
t.circle(-30,90) 画90°的圆,半径30像素
t.circle(-100,360,1000) 画圆(顺时针),半径100像素,指定该圆
有1000个近似多边形内接而成
t.home()回到原定位置(0.0)
t.dot(10,‘red’) 画点&