python画个小黄人
时间: 2023-07-25 10:26:23 浏览: 89
用python画小黄人源码
要画小黄人,可以使用Python中的turtle库。以下是一个简单的例子:
```python
import turtle
# 设置画笔尺寸和速度
turtle.pensize(10)
turtle.speed(10)
# 画身体
turtle.fillcolor('yellow')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-60, 120)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(-60, 120)
turtle.pendown()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 120)
turtle.pendown()
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 120)
turtle.pendown()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-80, 20)
turtle.pendown()
turtle.right(60)
turtle.circle(80, 120)
# 画手
turtle.penup()
turtle.goto(-100, -50)
turtle.pendown()
turtle.right(30)
turtle.forward(80)
turtle.right(120)
turtle.forward(80)
turtle.right(180)
turtle.penup()
turtle.forward(80)
turtle.right(60)
turtle.pendown()
turtle.forward(80)
turtle.right(120)
turtle.forward(80)
# 画脚
turtle.penup()
turtle.goto(-60, -150)
turtle.pendown()
turtle.right(30)
turtle.forward(80)
turtle.right(180)
turtle.forward(80)
turtle.penup()
turtle.goto(60, -150)
turtle.pendown()
turtle.right(150)
turtle.forward(80)
turtle.right(180)
turtle.forward(80)
turtle.done()
```
这个例子使用turtle库画出了一个小黄人的图像,其中包括了身体、眼睛、嘴巴、手和脚等元素。
阅读全文