python 爱心 代码
时间: 2023-12-10 08:36:17 浏览: 138
以下是一个Python爱心代码的例子:
```python
import math
import turtle
def drawHeart():
turtle.color('red', 'pink')
turtle.begin_fill()
turtle.left(140)
turtle.forward(180)
turtle.circle(-90, 200)
turtle.setheading(60)
turtle.circle(-90, 200)
turtle.forward(180)
turtle.end_fill()
def drawText():
turtle.penup()
turtle.goto(0, 0)
turtle.color('#CD5C5C')
turtle.write('I Love You', font=('Arial', 30), align="center")
def main():
turtle.setup(width=600, height=400)
turtle.speed(0)
turtle.penup()
turtle.goto(0, -180)
turtle.pendown()
drawHeart()
drawText()
turtle.hideturtle()
turtle.done()
if __name__ == '__main__':
main()
```
阅读全文