Python实现动态爱心表白
Python实现动态爱心表白
# 导入turtle库
import turtle
turtle.speed(1)
# 设置初始坐标
x = 0
y = -150
turtle.penup()
turtle.goto(x, y)
# 绘制爱心
turtle.fillcolor('red')
turtle.pendown()
turtle.begin_fill()
turtle.goto(0, 50)
turtle.goto(50, 100)
turtle.goto(100, 50)
turtle.goto(0, -150)
turtle.goto(-100, 50)
turtle.goto(-50, 100)
turtle.goto(0, 50)
turtle.end_fill()
# 输出表白语句
turtle.penup()
turtle.goto(x, y + 50)
turtle.write("亲爱的XXX:", align="center", font=("华文行楷", 25, "normal"))
turtle.goto(x, y + 20)
turtle.write("我爱你哦!", align="center", font=("华文行楷", 25, "normal"))
# 隐藏画笔
turtle.hideturtle()
turtle.done()
# 导入turtle库
import turtle
turtle.speed(1)
# 设置初始坐标
x = 0
y = -150
turtle.penup()
turtle.goto(x, y)
# 绘制爱心
turtle.fillcolor('red')
turtle.pendown()
turtle.begin_fill()
turtle.goto(0, 50)
turtle.goto(50, 100)
turtle.goto(100, 50)
turtle.goto(0, -150)
turtle.goto(-100, 50)
turtle.goto(-50, 100)
turtle.goto(0, 50)
turtle.end_fill()
# 输出表白语句
turtle.penup()
turtle.goto(x, y + 50)
turtle.write("亲爱的XXX:", align="center", font=("华文行楷", 25, "normal"))
turtle.goto(x, y + 20)
turtle.write("我爱你哦!", align="center", font=("华文行楷", 25, "normal"))
# 隐藏画笔
turtle.hideturtle()
turtle.done()
用户评论