用Python画小黄人
时间: 2023-12-25 09:28:37 浏览: 75
以下是用Python Turtle库画小黄人的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("white")
# 画身体
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.begin_fill()
turtle.color("yellow")
turtle.circle(200)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(-70, 80)
turtle.pendown()
turtle.begin_fill()
turtle.color("white")
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(-70, 100)
turtle.pendown()
turtle.begin_fill()
turtle.color("black")
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(70, 80)
turtle.pendown()
turtle.begin_fill()
turtle.color("white")
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(70, 100)
turtle.pendown()
turtle.begin_fill()
turtle.color("black")
turtle.circle(20)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-100, -50)
turtle.pendown()
turtle.pensize(20)
turtle.right(45)
turtle.forward(100)
turtle.penup()
turtle.goto(100, -50)
turtle.pendown()
turtle.left(90)
turtle.forward(100)
# 画背带
turtle.penup()
turtle.goto(-150, 0)
turtle.pendown()
turtle.begin_fill()
turtle.color("blue")
turtle.right(45)
turtle.forward(100)
turtle.right(90)
turtle.forward(50)
turtle.right(90)
turtle.forward(100)
turtle.right(135)
turtle.forward(70)
turtle.end_fill()
turtle.penup()
turtle.goto(150, 0)
turtle.pendown()
turtle.begin_fill()
turtle.color("blue")
turtle.left(45)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(135)
turtle.forward(70)
turtle.end_fill()
# 完成
turtle.done()
```
阅读全文