代码点读机 / Python / turtle

turtle Python · 常用模块

海龟绘图模块,通过控制小海龟移动来画图,适合编程入门。

怎么用

import turtle

小例子

import turtle
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
print('画完了')

运行结果

画完了

提醒:运行时会弹出绘图窗口;程序末尾常用 turtle.done() 保持窗口。

官方文档:https://docs.python.org/zh-cn/3/library/turtle.html

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条