```python
import turtle
def draw_heart():
penup()
goto(0, -100)
pendown()
color('red')
begin_fill()
setheading(150)
circle(200, 90)
left(90)
circle(200, 90)
end_fill()
hideturtle()
draw_heart()
turtle.done()
```
这段代码首先导入了turtle库,然后定义了一个名为`draw_heart`的函数,该函数使用turtle库的API来绘制一个爱心形状。函数中,`penup()`和`pendown()`用于控制画笔的移动,`color('red')`设置画笔颜色为红色,`begin_fill()`和`end_fill()`用于填充颜色,`circle(200, 90)`用于绘制圆形,`setheading(150)`设置画笔的朝向,`left(90)`用于旋转画笔。
运行这段代码,你将在屏幕上看到一个红色的爱心形状。你可以根据需要修改代码中的参数,例如改变爱心的大小、颜色或位置。