用python画派大星
时间: 2023-08-04 17:20:07 浏览: 388
派大星学院选课系统.rar
可以使用 Python 中的 turtle 库来画出派大星。
下面是一个简单的示例代码:
```python
import turtle
# 设置画笔
turtle.pensize(4)
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
# 画身体
turtle.fillcolor('yellow')
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 画眼睛
turtle.fillcolor('white')
turtle.penup()
turtle.goto(-60, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 120)
turtle.pendown()
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 画瞳孔
turtle.fillcolor('black')
turtle.penup()
turtle.goto(-60, 130)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(60, 130)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 画嘴巴
turtle.penup()
turtle.goto(-70, 0)
turtle.pendown()
turtle.right(60)
turtle.circle(80, 120)
# 画胡须
turtle.pensize(2)
turtle.penup()
turtle.goto(-20, 80)
turtle.pendown()
turtle.goto(-80, 80)
turtle.penup()
turtle.goto(-20, 60)
turtle.pendown()
turtle.goto(-80, 60)
turtle.penup()
turtle.goto(-20, 40)
turtle.pendown()
turtle.goto(-80, 40)
turtle.penup()
turtle.goto(20, 80)
turtle.pendown()
turtle.goto(80, 80)
turtle.penup()
turtle.goto(20, 60)
turtle.pendown()
turtle.goto(80, 60)
turtle.penup()
turtle.goto(20, 40)
turtle.pendown()
turtle.goto(80, 40)
# 隐藏画笔
turtle.hideturtle()
turtle.done()
```
运行代码后,就可以看到画出的派大星啦!
阅读全文