python爱心表白 每天都是浪漫七夕!
Python  /  管理员 发布于 7年前   237
本文为大家分享了python爱心表白的具体代码,供大家参考,具体内容如下
import turtleimport time# 画爱心的顶部def LittleHeart(): for i in range(200): turtle.right(1) turtle.forward(2)# 输入表白的语句,默认I Love youlove = 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,0turtle.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()
运行结果:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号