用python turtle 画一个小乌龟头
时间: 2023-11-03 10:06:28 浏览: 142
python用turtle画画
以下是一个简单的示例代码,可以画一个小乌龟头:
```python
import turtle
turtle.speed(0)
# 画头
turtle.penup()
turtle.goto(0, 200)
turtle.pendown()
turtle.color("black", "yellow")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-50, 250)
turtle.pendown()
turtle.color("black", "white")
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 250)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画瞳孔
turtle.penup()
turtle.goto(-50, 250)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(50, 250)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 完成
turtle.hideturtle()
turtle.done()
```
运行上述代码后,会弹出一个窗口,显示出画出来的小乌龟头。你可以根据需要自行修改代码,来画出不同形状的小乌龟头。
阅读全文