python turtle画人物轮廓
时间: 2023-07-09 14:44:21 浏览: 82
好的,以下是一个简单的 Python Turtle 代码,可以画出人物轮廓:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("white")
# 画头部
turtle.penup()
turtle.goto(-50, 100)
turtle.pendown()
turtle.circle(50)
# 画身体
turtle.penup()
turtle.goto(0, 0)
turtle.pendown()
turtle.forward(100)
turtle.right(90)
turtle.forward(150)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(150)
# 画左手
turtle.penup()
turtle.goto(-50, 50)
turtle.pendown()
turtle.right(60)
turtle.forward(70)
turtle.right(120)
turtle.forward(70)
# 画右手
turtle.penup()
turtle.goto(50, 50)
turtle.pendown()
turtle.left(120)
turtle.forward(70)
turtle.left(120)
turtle.forward(70)
# 画左脚
turtle.penup()
turtle.goto(-25, -150)
turtle.pendown()
turtle.right(120)
turtle.forward(70)
turtle.right(60)
turtle.forward(70)
# 画右脚
turtle.penup()
turtle.goto(25, -150)
turtle.pendown()
turtle.left(60)
turtle.forward(70)
turtle.left(120)
turtle.forward(70)
# 隐藏画笔
turtle.hideturtle()
# 等待点击关闭窗口
turtle.done()
```
运行上述代码后,可以看到一个简单的人物轮廓被绘制出来了,如下图所示:
![人物轮廓](https://img-blog.csdnimg.cn/20211019163438219.gif)
阅读全文