python爱心表白 每天都是浪漫七夕!


Posted in Python onAugust 18, 2018

本文为大家分享了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()

运行结果:

python爱心表白 每天都是浪漫七夕!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python实现中一次读取多个值的方法
Apr 22 Python
配置 Pycharm 默认 Test runner 的图文教程
Nov 30 Python
python实现向微信用户发送每日一句 python实现微信聊天机器人
Mar 27 Python
TensorFlow车牌识别完整版代码(含车牌数据集)
Aug 05 Python
python使用matplotlib绘制雷达图
Oct 18 Python
django框架基于queryset和双下划线的跨表查询操作详解
Dec 11 Python
tensorflow没有output结点,存储成pb文件的例子
Jan 04 Python
python数据库操作mysql:pymysql、sqlalchemy常见用法详解
Mar 30 Python
python3.7添加dlib模块的方法
Jul 01 Python
Python常用库Numpy进行矩阵运算详解
Jul 21 Python
Python浮点型(float)运算结果不正确的解决方案
Sep 22 Python
用pushplus+python监控亚马逊到货动态推送微信
Jan 29 Python
Python实现全排列的打印
Aug 18 #Python
python递归实现快速排序
Aug 18 #Python
pyqt5的QWebEngineView 使用模板的方法
Aug 18 #Python
python递归全排列实现方法
Aug 18 #Python
python使用PIL给图片添加文字生成海报示例
Aug 17 #Python
Python在for循环中更改list值的方法【推荐】
Aug 17 #Python
Python简单读写Xls格式文档的方法示例
Aug 17 #Python
You might like
追求程序速度,而不是编程的速度
2008/04/23 PHP
PHP中的use关键字概述
2014/07/23 PHP
composer.lock文件的作用
2016/02/03 PHP
php集成动态口令认证
2016/07/21 PHP
详细解读php的命名空间(二)
2018/02/21 PHP
Javascript 构造函数 实例分析
2008/11/26 Javascript
JavaScript 函数的执行过程
2016/05/09 Javascript
JS使用正则表达式实现关键字替换加粗功能示例
2016/08/03 Javascript
JavaScript中自带的 reduce()方法使用示例详解
2016/08/10 Javascript
jQuery实现checkbox列表的全选、反选功能
2016/11/24 Javascript
基于vue2框架的机器人自动回复mini-project实例代码
2017/06/13 Javascript
JavaScript中数组去重的5种方法
2020/07/04 Javascript
Python中使用动态变量名的方法
2014/05/06 Python
python通过floor函数舍弃小数位的方法
2015/03/17 Python
Python 编码Basic Auth使用方法简单实例
2017/05/25 Python
Django 表单模型选择框如何使用分组
2019/05/16 Python
Python数据分析模块pandas用法详解
2019/09/04 Python
Python通过Manager方式实现多个无关联进程共享数据的实现
2019/11/07 Python
VSCode中自动为Python文件添加头部注释
2019/11/14 Python
Python实现FLV视频拼接功能
2020/01/21 Python
在django中使用apscheduler 执行计划任务的实现方法
2020/02/11 Python
Python键鼠操作自动化库PyAutoGUI简介(小结)
2020/05/17 Python
Python网页解析器使用实例详解
2020/05/30 Python
深入了解python列表(LIST)
2020/06/08 Python
基于opencv的selenium滑动验证码的实现
2020/07/24 Python
Python实现列表索引批量删除的5种方法
2020/11/16 Python
伦敦哈德森鞋:Hudson Shoes
2018/02/06 全球购物
销售总监工作职责
2013/11/21 职场文书
酒店总经理助理职责
2014/02/12 职场文书
活动总结的格式
2014/05/07 职场文书
汽车广告策划方案
2014/05/31 职场文书
商务英语专业大学生职业生涯规划书
2014/09/14 职场文书
先进个人自荐书
2015/03/06 职场文书
离婚起诉书怎么写
2015/05/19 职场文书
Python 文本滚动播放器的实现代码
2021/04/25 Python
python神经网络学习 使用Keras进行简单分类
2022/05/04 Python