python爱心表白 每天都是浪漫七夕!
作者:a289237642 时间:2023-02-26 20:36:55
本文为大家分享了python爱心表白的具体代码,供大家参考,具体内容如下
import turtle
import time
# 画爱心的顶部
def LittleHeart():
for i in range(200):
turtle.right(1)
turtle.forward(2)
# 输入表白的语句,默认I Love you
love = input('Please enter a sentence of love, otherwise the default is "I Love you": ')
# 输入署名或者赠谁,没有不执行
me = input('Please enter pen name, otherwise the default do not execute: ')
if love == '':
love = 'I Love you'
# 窗口大小
turtle.setup(width=900, height=500)
# 颜色
turtle.color('red', 'pink')
# 笔粗细
turtle.pensize(3)
# 速度
turtle.speed(1)
# 提笔
turtle.up()
# 隐藏笔
turtle.hideturtle()
# 去到的坐标,窗口中心为0,0
turtle.goto(0, -180)
turtle.showturtle()
# 画上线
turtle.down()
turtle.speed(1)
turtle.begin_fill()
turtle.left(140)
turtle.forward(224)
# 调用画爱心左边的顶部
LittleHeart()
# 调用画爱右边的顶部
turtle.left(120)
LittleHeart()
# 画下线
turtle.forward(224)
turtle.end_fill()
turtle.pensize(5)
turtle.up()
turtle.hideturtle()
# 在心中写字 一次
turtle.goto(0, 0)
turtle.showturtle()
turtle.color('#CD5C5C', 'pink')
# 在心中写字 font可以设置字体自己电脑有的都可以设 align开始写字的位置
turtle.write(love, font=('gungsuh', 30,), align="center")
turtle.up()
turtle.hideturtle()
time.sleep(2)
# 在心中写字 二次
turtle.goto(0, 0)
turtle.showturtle()
turtle.color('red', 'pink')
turtle.write(love, font=('gungsuh', 30,), align="center")
turtle.up()
turtle.hideturtle()
# 写署名
if me != '':
turtle.color('black', 'pink')
time.sleep(2)
turtle.goto(180, -180)
turtle.showturtle()
turtle.write(me, font=(20,), align="center", move=True)
# 点击窗口关闭
window = turtle.Screen()
window.exitonclick()
运行结果:
来源:https://blog.csdn.net/a289237642/article/details/80372781
标签:python,表白
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
vue实现一个单独的组件注释
2024-04-27 15:47:04
![](https://img.aspxhome.com/file/2023/6/133156_0s.jpg)
使用python画出逻辑斯蒂映射(logistic map)中的分叉图案例
2023-05-19 13:05:18
![](https://img.aspxhome.com/file/2023/9/90709_0s.jpg)
pytz格式化北京时间多出6分钟问题的解决方法
2021-07-31 14:10:21
python 模拟登陆github的示例
2022-01-05 17:52:41
![](https://img.aspxhome.com/file/2023/4/134674_0s.png)
pytorch关于Tensor的数据类型说明
2023-08-22 20:39:27
![](https://img.aspxhome.com/file/2023/8/85288_0s.png)
这十大Python库你真应该知道
2022-09-20 00:09:03
![](https://img.aspxhome.com/file/2023/0/134990_0s.jpg)
scrapy数据存储在mysql数据库的两种方式(同步和异步)
2023-07-10 03:29:43
![](https://img.aspxhome.com/file/2023/4/62304_0s.png)
mysql千万级数据大表该如何优化?
2024-01-20 22:08:05
python 中文件输入输出及os模块对文件系统的操作方法
2023-04-10 18:34:05
在select语句中使用top的一些小技巧
2009-03-12 12:21:00
python中如何使用朴素贝叶斯算法
2023-02-26 08:51:39
![](https://img.aspxhome.com/file/2023/5/95795_0s.png)
Python常用的json标准库
2022-02-26 10:37:52
通用javascript代码判断版本号是否在版本范围之间
2024-06-11 03:47:44
Python项目打包成二进制的方法
2023-11-07 05:22:02
python中正则表达式与模式匹配
2023-08-25 22:54:59
![](https://img.aspxhome.com/file/2023/2/97132_0s.png)
Python3实现爬取简书首页文章标题和文章链接的方法【测试可用】
2021-10-08 00:22:10
![](https://img.aspxhome.com/file/2023/4/89334_0s.png)
深入浅出MySQL双向复制技术
2009-03-25 15:40:00
cmd运行python文件时对结果进行保存的方法
2023-03-12 03:18:02
![](https://img.aspxhome.com/file/2023/5/92185_0s.jpg)
Python爬虫程序中使用生产者与消费者模式时进程过早退出的问题
2022-10-12 03:37:52
laravel添加前台跳转成功页面示例
2023-11-20 15:22:18