turtle简介
turtle(海龟)绘图很适合用来引导少儿学习编程,通过简单的命令,可以轻松地绘制出精美的形状和图案。
常用命令介绍
更多命令可以参见:https://docs.python.org/zh-cn/3/library/turtle.html#introduction
forward() | fd() 前进
backward() | bk() | back() 后退
right() | rt() 右转
left() | lt() 左转
goto() | setpos() | setposition() 前往/定位
setx() 设置x坐标
sety() 设置y坐标
setheading() | seth() 设置朝向
home() 返回原点
circle() 画圆
dot() 画点
stamp() 印章
clearstamp() 清除印章
clearstamps() 清除多个印章
undo() 撤消
speed() 速度
画基本图形的效果
画基本图形的代码
from turtle import *
import turtle
from math import *
def draw_star():
down()
for i