python画一个吉祥物
时间: 2024-12-20 07:19:50 浏览: 22
在Python中,我们可以使用`turtle`模块来创建一个简单的吉祥物图像,比如卡通小兔子。下面是一个简化的示例:
```python
import turtle
# 定义吉祥物 - 小兔子
def draw_rabbit():
turtle.penup()
turtle.goto(-50, -40)
turtle.pendown()
# 耳朵
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.right(90)
turtle.forward(60)
turtle.left(180)
turtle.circle(20)
turtle.right(90)
# 眼睛
turtle.penup()
turtle.goto(-20, -20)
turtle.pendown()
turtle.color("black")
turtle.dot(10)
turtle.penup()
turtle.goto(-10, -20)
turtle.pendown()
turtle.dot(10)
# 鼻子
turtle.penup()
turtle.goto(-25, -10)
turtle.pendown()
turtle.color("red")
turtle.dot(5)
# 嘴巴
turtle.penup()
turtle.goto(-20, -5)
turtle.pendown()
turtle.right(90)
turtle.forward(15)
turtle.right(135)
turtle.forward(10)
# 身体和脚
turtle.color("gray")
turtle.begin_fill()
turtle.circle(40)
turtle.end_fill()
turtle.penup()
turtle.goto(-50, 10)
turtle.pendown()
turtle.forward(70)
turtle.right(90)
turtle.forward(30)
turtle.right(90)
turtle.forward(70)
# 创建画布并绘制小兔子
window = turtle.Screen()
window.bgcolor("white")
my_turtle = turtle.Turtle()
draw_rabbit()
turtle.done()
阅读全文