python画个懒洋洋
时间: 2023-11-07 15:04:37 浏览: 152
你可以使用Python的Turtle库来绘制一个可爱的懒羊羊。可以通过以下代码实现:
import turtle
# 设置画布
canvas = turtle.Screen()
canvas.bgcolor("white")
# 创建一个画笔
pen = turtle.Turtle()
pen.color("black")
# 绘制懒羊羊的头部
pen.penup()
pen.goto(0, -100)
pen.pendown()
pen.circle(100)
# 绘制懒羊羊的眼睛
pen.penup()
pen.goto(-40, 0)
pen.pendown()
pen.circle(20)
pen.penup()
pen.goto(40, 0)
pen.pendown()
pen.circle(20)
# 绘制懒羊羊的嘴巴
pen.penup()
pen.goto(-60, -40)
pen.pendown()
pen.goto(60, -40)
# 绘制懒羊羊的身体
pen.penup()
pen.goto(-100, -200)
pen.pendown()
pen.circle(100)
# 绘制懒羊羊的腿
pen.penup()
pen.goto(-80, -300)
pen.pendown()
pen.goto(-120, -300)
pen.penup()
pen.goto(80, -300)
pen.pendown()
pen.goto(120, -300)
# 绘制懒羊羊的尾巴
pen.penup()
pen.goto(0, -300)
pen.pendown()
pen.goto(0, -250)
# 隐藏画笔
pen.hideturtle()
# 关闭画布
canvas.exitonclick()
阅读全文