跳动的心代码python
时间: 2023-11-22 11:46:54 浏览: 708
爱心跳动-HTML实现.rar
5星 · 资源好评率100%
以下是绘制跳动的心的Python代码:
```python
import turtle
# 画爱心的函数
def draw_heart():
turtle.color('red', 'pink')
turtle.begin_fill()
turtle.left(45)
turtle.forward(100)
turtle.circle(50, 180)
turtle.right(90)
turtle.circle(50, 180)
turtle.forward(100)
turtle.end_fill()
# 设置画笔的属性
turtle.pensize(3)
turtle.speed(1)
turtle.penup()
turtle.goto(0, -180)
turtle.pendown()
# 循环绘制跳动的心
while True:
turtle.clear()
draw_heart()
turtle.left(45)
turtle.forward(10)
turtle.right(45)
turtle.forward(10)
```
阅读全文