python turtle库画史迪奇源代码
时间: 2024-01-12 22:01:31 浏览: 228
```python
import turtle
# 设置画布和海龟
wn = turtle.Screen()
wn.bgcolor("white")
snoopy = turtle.Turtle()
snoopy.shape("turtle")
snoopy.color("black")
# 画脸
snoopy.begin_fill()
snoopy.circle(100)
snoopy.end_fill()
# 画眼睛
snoopy.penup()
snoopy.goto(-35, 120)
snoopy.pendown()
snoopy.dot(25)
snoopy.penup()
snoopy.goto(35, 120)
snoopy.pendown()
snoopy.dot(25)
# 画鼻子
snoopy.penup()
snoopy.goto(0, 90)
snoopy.pendown()
snoopy.dot(15)
# 画嘴巴
snoopy.penup()
snoopy.goto(0, 60)
snoopy.pendown()
snoopy.right(90)
snoopy.circle(20, 180)
# 画耳朵
snoopy.penup()
snoopy.goto(-100, 90)
snoopy.pendown()
snoopy.begin_fill()
snoopy.circle(30, 180)
snoopy.end_fill()
snoopy.penup()
snoopy.goto(100, 90)
snoopy.pendown()
snoopy.begin_fill()
snoopy.circle(30, -180)
snoopy.end_fill()
# 画身体
snoopy.penup()
snoopy.goto(0, -100)
snoopy.pendown()
snoopy.begin_fill()
snoopy.circle(100, -180)
snoopy.left(90)
snoopy.forward(200)
snoopy.left(90)
snoopy.circle(100, -180)
snoopy.end_fill()
# 完成
snoopy.hideturtle()
wn.mainloop()
```
阅读全文