用python写一个母亲节的贺卡
时间: 2024-04-30 12:18:19 浏览: 113
好的,以下是一个简单的母亲节贺卡的Python代码:
```python
import turtle
# 设置画布和画笔
canvas = turtle.Screen()
canvas.bgcolor("#FBD3E6")
pen = turtle.Turtle()
pen.speed(0)
pen.penup()
pen.hideturtle()
# 写上贺卡标题
pen.goto(0, 200)
pen.write("Happy Mother's Day!", align="center", font=("Arial", 40, "bold"))
# 画出花朵
pen.goto(-200, 0)
pen.pendown()
pen.color("#FF69B4")
for i in range(5):
pen.forward(100)
pen.right(144)
pen.penup()
pen.goto(200, 0)
pen.pendown()
for i in range(5):
pen.forward(100)
pen.right(144)
# 写上祝福语
pen.color("#000000")
pen.penup()
pen.goto(0, -100)
pen.write("Thank you for being the best mom in the world!", align="center", font=("Arial", 20, "normal"))
turtle.done()
```
运行上述代码后,将在屏幕上绘制出一个粉色背景的母亲节贺卡,包括一个“Happy Mother's Day!”的标题、两个五角星花朵和一条“Thank you for being the best mom in the world!”的祝福语。你可以根据你的喜好和创意自由修改和美化这个贺卡。
阅读全文