1.Python turtle 库
1.turtle库
导入模块
格式:import 模块名 as 别名
import turtle as t
turtle 库函数
| 函数名 | 使用方式 | 作用 |
|---|---|---|
| forward()或fd() | turtle.fd(长度) | 直走 |
| backward()或bk() | turtle.bk(长度) | 后退 |
| left() | turtle.left(度数) | 左转 |
| right() | turtle.right(度数) | 右转 |
| done() | turtle.done() | 写在最后,让画图界面长时间存在 |
| circle() | turtle.circle(圆的半径,圆心角) | 绘制圆 |
| goto() | turtle.goto(x,y) | 移到指定坐标 |
| penup() | turtle.penup() | 抬笔 |
| pendown() | turtle.pendown() | 落笔 |
| fillcolor() | turtle.fillcolor('颜色名') | 设置填充颜色 |
| begin_fill() | turtle.begin_fill() | 开始填充 |
| end_fill() | turtle.end_fill() | 结束填充 |
| colormode() | turtle.colormode(255) | RGB整数模式,使用三原色前必须写这一行 |
| color() | turtle.color(pencolor,fillcolor) | 同时设置笔的颜色和填充颜色 |
天助自助者

浙公网安备 33010602011771号