python画龙猫_龙猫python
时间: 2023-06-23 18:53:13 浏览: 246
好的,以下是使用Python Turtle库画一只龙猫的代码:
```python
import turtle
# 设置画布大小和背景颜色
turtle.setup(600, 600)
turtle.bgcolor("lightblue")
# 画身体
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
# 画头
turtle.penup()
turtle.goto(0, 50)
turtle.pendown()
turtle.begin_fill()
turtle.circle(30)
turtle.end_fill()
# 画耳朵
turtle.penup()
turtle.goto(15, 80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-15, 80)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.goto(10, 60)
turtle.pendown()
turtle.dot(10)
turtle.penup()
turtle.goto(-10, 60)
turtle.pendown()
turtle.dot(10)
# 画嘴巴
turtle.penup()
turtle.goto(0, 40)
turtle.pendown()
turtle.right(90)
turtle.circle(10, 180)
# 画手臂
turtle.penup()
turtle.goto(-80, 20)
turtle.pendown()
turtle.right(30)
turtle.forward(40)
turtle.right(90)
turtle.forward(40)
turtle.right(180)
turtle.forward(40)
turtle.right(60)
turtle.forward(40)
turtle.penup()
turtle.goto(80, 20)
turtle.pendown()
turtle.left(30)
turtle.forward(40)
turtle.left(90)
turtle.forward(40)
turtle.left(180)
turtle.forward(40)
turtle.left(60)
turtle.forward(40)
# 隐藏画笔
turtle.hideturtle()
# 显示窗口
turtle.mainloop()
```
运行以上代码,即可看到一只可爱的龙猫出现在窗口中。
阅读全文