python同时画两条蟒蛇
时间: 2023-11-01 20:57:39 浏览: 128
要同时画两条蟒蛇,你可以在代码中添加一个循环来重复画第二条蟒蛇。以下是一个示例代码:
```
import turtle
def draw_snake():
turtle.penup()
turtle.fd(-300)
turtle.pendown()
turtle.pensize(20)
turtle.pencolor("black")
turtle.circle(-40, 40)
turtle.pensize(30)
turtle.pencolor("red")
turtle.seth(-40)
for i in range(2):
turtle.circle(80, 100)
turtle.pencolor("purple")
turtle.circle(-80, 100)
turtle.pencolor("yellow")
turtle.pencolor("green")
turtle.circle(80, 80)
turtle.fd(80)
turtle.circle(16, 180)
turtle.fd(80 * 2/3)
turtle.circle(50, -80)
turtle.fd(80 * 2/3)
turtle.speed(1) # 控制绘制速度
# 画第一条蟒蛇
draw_snake()
# 画第二条蟒蛇
turtle.penup()
turtle.goto(200, 0) # 移动到新的起始位置
turtle.pendown()
draw_snake()
turtle.done()
```
阅读全文