Python画懒羊羊
时间: 2023-11-19 12:50:41 浏览: 165
Python 画懒羊羊可以使用 Turtle 库完成。具体代码如下:
```
import turtle
# 设置画笔大小和颜色
turtle.pensize(4)
turtle.pencolor('black')
# 绘制羊头
turtle.circle(50)
turtle.penup()
turtle.goto(0, 100)
turtle.pendown()
turtle.circle(20)
turtle.penup()
turtle.goto(-20, 120)
turtle.pendown()
turtle.circle(5)
turtle.penup()
turtle.goto(20, 120)
turtle.pendown()
turtle.circle(5)
# 绘制羊身
turtle.penup()
turtle.goto(0, 50)
turtle.pendown()
turtle.goto(0, -50)
turtle.penup()
# 绘制羊腿
turtle.goto(-40, -50)
turtle.pendown()
turtle.goto(-40, -90)
turtle.penup()
turtle.goto(-20, -50)
turtle.pendown()
turtle.goto(-20, -90)
turtle.penup()
turtle.goto(40, -50)
turtle.pendown()
turtle.goto(40, -90)
turtle.penup()
turtle.goto(20, -50)
turtle.pendown()
turtle.goto(20, -90)
# 完成绘画
turtle.done()
```
阅读全文