Python 史迪仔
时间: 2023-12-25 10:28:40 浏览: 48
以下是使用Python turtle库绘制史迪仔的代码和效果图:
```python
import turtle
# 设置画笔
t = turtle.Pen()
t.pensize(5)
t.speed(10)
# 绘制头部
t.fillcolor('#FED85D')
t.begin_fill()
t.circle(100)
t.end_fill()
# 绘制眼睛
t.penup()
t.goto(-40, 120)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.circle(30)
t.end_fill()
t.penup()
t.goto(-30, 130)
t.pendown()
t.fillcolor('black')
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()
t.goto(40, 120)
t.pendown()
t.fillcolor('white')
t.begin_fill()
t.circle(30)
t.end_fill()
t.penup()
t.goto(30, 130)
t.pendown()
t.fillcolor('black')
t.begin_fill()
t.circle(15)
t.end_fill()
# 绘制嘴巴
t.penup()
t.goto(-60, 60)
t.pendown()
t.right(45)
t.circle(80, 90)
# 绘制身体
t.penup()
t.goto(-100, -100)
t.pendown()
t.fillcolor('#FED85D')
t.begin_fill()
t.right(135)
t.forward(200)
t.right(45)
t.circle(80, 90)
t.right(45)
t.forward(200)
t.right(135)
t.circle(100, 180)
t.end_fill()
# 绘制手臂
t.penup()
t.goto(-200, -100)
t.pendown()
t.fillcolor('#FED85D')
t.begin_fill()
t.right(45)
t.forward(100)
t.right(45)
t.circle(80, 90)
t.right(45)
t.forward(100)
t.right(135)
t.circle(100, 180)
t.end_fill()
t.penup()
t.goto(100, -100)
t.pendown()
t.fillcolor('#FED85D')
t.begin_fill()
t.right(135)
t.forward(100)
t.right(45)
t.circle(-80, 90)
t.right(45)
t.forward(100)
t.right(135)
t.circle(-100, 180)
t.end_fill()
# 绘制脚
t.penup()
t.goto(-100, -300)
t.pendown()
t.fillcolor('#FED85D')
t.begin_fill()
t.right(45)
t.forward(100)
t.right(45)
t.circle(80, 90)
t.right(45)
t.forward(100)
t.right(135)
t.circle(100, 180)
t.end_fill()
t.penup()
t.goto(100, -300)
t.pendown()
t.fillcolor('#FED85D')
t.begin_fill()
t.right(135)
t.forward(100)
t.right(45)
t.circle(-80, 90)
t.right(45)
t.forward(100)
t.right(135)
t.circle(-100, 180)
t.end_fill()
# 隐藏画笔
t.hideturtle()
# 等待点击关闭窗口
turtle.done()
```
绘制效果图如下:
![史迪仔](https://i.loli.net/2021/08/12/7J5zvKZV8Q6q1fS.png)