520到了,还被女朋友问送什么礼物吗?鲜花?口红?看电影?很俗的好不好,给你女朋友一个程序员的Surprise吧,来来来,让你用代码撩妹子。啥?没有女朋友?没有女朋友更应该看了,用它来表白不香嘛?

1、引言

什么什么?你女朋友不懂代码?没有编译环境?这叫事儿嘛,以下你看到的所有代码,我都给你打包成电脑一键运行exe程序,双击就完事儿。就问你女朋友喜不喜欢,文章末尾自取即可。

我还在每个文件夹中写了使用说明,你确定不要吗?尤其是最后一个,非常好看哦。

2、代码列表

  • 浪漫玫瑰

  • 浪漫玫瑰加爱心

  • 你中有我,我中有你

  • 浪漫小树

  • 用女朋友照片,绘制心形

  • 电脑弹窗表白

  • 字符画-用字符画出来你女朋友(尤其是这个,我最喜欢了)

3、浪漫玫瑰

成品展示

源代码

from turtle import *
import timesetup(1000, 800, 0, 0)
speed(0)
penup()
seth(90)
fd(340)
seth(0)
pendown()speed(5)
begin_fill()
fillcolor('red')
circle(50, 30)for i in range(10):fd(1)left(10)circle(40, 40)for i in range(6):fd(1)left(3)circle(80, 40)for i in range(20):fd(0.5)left(5)circle(80, 45)for i in range(10):fd(2)left(1)circle(80, 25)for i in range(20):fd(1)left(4)circle(50, 50)time.sleep(0.1)circle(120, 55)speed(0)seth(-90)
fd(70)right(150)
fd(20)left(140)
circle(140, 90)left(30)
circle(160, 100)left(130)
fd(25)penup()
right(150)
circle(40, 80)
pendown()left(115)
fd(60)penup()
left(180)
fd(60)
pendown()end_fill()right(120)
circle(-50, 50)
circle(-20, 90)speed(1)
fd(75)speed(0)
circle(90, 110)penup()
left(162)
fd(185)
left(170)
pendown()
circle(200, 10)
circle(100, 40)
circle(-52, 115)
left(20)
circle(100, 20)
circle(300, 20)
speed(1)
fd(250)penup()
speed(0)
left(180)
fd(250)
circle(-300, 7)
right(80)
circle(200, 5)
pendown()left(60)
begin_fill()
fillcolor('green')
circle(-80, 100)
right(90)
fd(10)
left(20)
circle(-63, 127)
end_fill()penup()
left(50)
fd(20)
left(180)pendown()
circle(200, 25)penup()
right(150)fd(180)right(40)
pendown()
begin_fill()
fillcolor('green')
circle(-100, 80)
right(150)
fd(10)
left(60)
circle(-80, 98)
end_fill()penup()
left(60)
fd(13)
left(180)pendown()
speed(1)
circle(-200, 23)exitonclick()

4、浪漫玫瑰加爱心

成品展示

源代码

import turtle
import time# 爱心函数
def yellowheart(x, y, liftx):turtle.pensize(3)turtle.speed(10)turtle.color("red", "red")turtle.up()turtle.goto(x, y)turtle.down()turtle.begin_fill()turtle.left(liftx)turtle.fd(80)turtle.circle(-40, 180)turtle.left(90)turtle.circle(-40, 180)turtle.left(0)turtle.fd(80)turtle.end_fill()def rose():turtle.speed(0)  # 画笔移动的速度# turtle.tracer(False)# 设置初始位置turtle.penup()  # 提起画笔turtle.left(90)  # 逆时针转动画笔90度turtle.fd(200)turtle.pendown()  # 放下画笔,移动画笔即开始绘制turtle.right(90)# 设置画笔的大小turtle.pensize(2)# 花蕊turtle.fillcolor("red")  # 填充颜色turtle.begin_fill()  # 开始填充turtle.circle(10, 180)turtle.circle(25, 110)turtle.left(50)turtle.circle(60, 45)turtle.circle(20, 170)turtle.right(24)turtle.fd(30)turtle.left(10)turtle.circle(30, 110)turtle.fd(20)turtle.left(40)turtle.circle(90, 70)turtle.circle(30, 150)turtle.right(30)turtle.fd(15)turtle.circle(80, 90)turtle.left(15)turtle.fd(45)turtle.right(165)turtle.fd(20)turtle.left(155)turtle.circle(150, 80)turtle.left(50)turtle.circle(150, 90)turtle.end_fill()  # 结束填充# 右侧花瓣turtle.left(150)turtle.circle(-90, 70)turtle.left(20)turtle.circle(75, 105)turtle.setheading(60)turtle.circle(80, 98)turtle.circle(-90, 40)# 左侧花瓣turtle.left(180)turtle.circle(90, 40)turtle.circle(-80, 98)turtle.setheading(-83)# 左侧叶子turtle.fd(30)turtle.left(90)turtle.fd(25)turtle.left(45)turtle.fillcolor("green")turtle.begin_fill()turtle.circle(-80, 90)turtle.right(90)turtle.circle(-80, 90)turtle.end_fill()turtle.right(135)turtle.fd(60)turtle.left(180)turtle.fd(85)turtle.left(90)turtle.fd(80)# 右侧叶子turtle.right(90)turtle.right(45)turtle.fillcolor("green")turtle.begin_fill()turtle.circle(80, 90)turtle.left(90)turtle.circle(80, 90)turtle.end_fill()turtle.left(135)turtle.fd(60)turtle.left(180)turtle.fd(60)turtle.right(90)turtle.circle(200, 50)  # 画一个圆 200 是半径,50 是弧度time.sleep(1)# turtle.tracer(False)# turtle.pensize(3)# turtle.speed(0)turtle.color("red", "red")turtle.up()turtle.goto(-230, 50)turtle.down()turtle.begin_fill()turtle.left(180)turtle.fd(80)turtle.circle(-40, 180)turtle.left(90)turtle.circle(-40, 180)turtle.left(0)turtle.fd(80)turtle.end_fill()time.sleep(1)# turtle.tracer(False)# turtle.pensize(3)# turtle.speed(0)turtle.color("red", "red")turtle.up()turtle.goto(-230, -80)turtle.down()turtle.begin_fill()turtle.left(-30)turtle.fd(80)turtle.circle(-40, 180)turtle.left(90)turtle.circle(-40, 180)turtle.left(0)turtle.fd(80)turtle.end_fill()time.sleep(1)# turtle.tracer(False)# turtle.pensize(3)# turtle.speed(0)turtle.color("red", "red")turtle.up()turtle.goto(-130, -180)turtle.down()turtle.begin_fill()turtle.left(-80)turtle.fd(80)turtle.circle(-40, 180)turtle.left(90)turtle.circle(-40, 180)turtle.left(0)turtle.fd(80)turtle.end_fill()time.sleep(1)# turtle.tracer(False)# turtle.pensize(3)# turtle.speed(0)turtle.color("red", "red")turtle.up()turtle.goto(200, -200)turtle.down()turtle.begin_fill()turtle.left(-90)turtle.fd(80)turtle.circle(-40, 180)turtle.left(90)turtle.circle(-40, 180)turtle.left(0)turtle.fd(80)turtle.end_fill()time.sleep(1)# turtle.tracer(False)# turtle.pensize(3)# turtle.speed(0)turtle.color("red", "red")turtle.up()turtle.goto(200, 50)turtle.down()turtle.begin_fill()turtle.left(90)turtle.fd(80)turtle.circle(-40, 180)turtle.left(90)turtle.circle(-40, 180)turtle.left(0)turtle.fd(80)turtle.end_fill()def figure1():turtle.reset()turtle.tracer(False)rose()yellowheart(-230, 50, 180)  # 左一# time.sleep(2)def figure2():# turtle.reset()turtle.tracer(False)rose()yellowheart(-230, -80, -30)  # 左二# time.sleep(2)def figure3():turtle.reset()turtle.tracer(False)rose()yellowheart(-130, -180, -30)  # 左三# time.sleep(2)def figure4():turtle.reset()turtle.tracer(False)rose()yellowheart(200, 50, 90)  # 右一# ime.sleep(2)def figure5():turtle.reset()turtle.tracer(False)rose()yellowheart(200, -200, -90)  # 右二# time.sleep(2)if __name__ == "__main__":rose()# figure1()## yellowheart(-230, -80, -30)  # 左二# 不让自动退出,放在程序的最后一行# 不然画画结束后会自动退出turtle.done()

5、你中有我,我中有你

成品展示

源代码

from turtle import *def go_to(x, y):up()goto(x, y)down()def small_Circle(size):  # 函数用于绘制心的小圆speed(10)for i in range(210):forward(size)right(0.786)def big_Circle(size):  # 函数用于绘制心的大圆speed(10)for i in range(150):forward(size)right(0.3)def line(size):speed(10)forward(51 * size)def heart(x, y, size):go_to(x, y)left(150)begin_fill()line(size)big_Circle(size)small_Circle(size)left(120)small_Circle(size)big_Circle(size)line(size)end_fill()def main():pensize(2)color('red', 'pink')getscreen().tracer(1, 0)heart(100, 0, 0.7)go_to(80, 70)write("官人", font=("楷体", 18, "normal"))setheading(0)heart(-80, -100, 1)go_to(-110, 15)write("娘子", font=("宋体", 20, "normal"))go_to(40, -80)write("三生三世皆是你!", move=True, align="left", font=("arial", 22, "italic"))done()main() 

6、浪漫小树

成品展示

源代码

import turtle as T
import random
import time# 画樱花的躯干(60,t)
def Tree(branch, t):time.sleep(0.0005)if branch > 3:if 8 <= branch <= 12:if random.randint(0, 2) == 0:t.color('snow')  # 白else:t.color('lightcoral')  # 淡珊瑚色t.pensize(branch / 3)elif branch < 8:if random.randint(0, 1) == 0:t.color('snow')else:t.color('lightcoral')  # 淡珊瑚色t.pensize(branch / 2)else:t.color('sienna')  # 赭(zhě)色t.pensize(branch / 10)  # 6t.forward(branch)a = 1.5 * random.random()t.right(20 * a)b = 1.5 * random.random()Tree(branch - 10 * b, t)t.left(40 * a)Tree(branch - 10 * b, t)t.right(20 * a)t.up()t.backward(branch)t.down()# 掉落的花瓣
def Petal(m, t):for i in range(m):a = 200 - 400 * random.random()b = 10 - 20 * random.random()t.up()t.forward(b)t.left(90)t.forward(a)t.down()t.color('lightcoral')  # 淡珊瑚色t.circle(1)t.up()t.backward(a)t.right(90)t.backward(b)# 绘图区域
t = T.Turtle()
# 画布大小
w = T.Screen()
t.hideturtle()  # 隐藏画笔
t.getscreen().tracer(5, 0)
w.screensize(bg='wheat')  # wheat小麦
t.left(90)
t.up()
t.backward(150)
t.down()
t.color('sienna')# 画樱花的躯干
Tree(60, t)
# 掉落的花瓣
Petal(200, t)
w.exitonclick()

7、用女朋友照片,绘制心形

成品展示

PS:我是每个照片放了三份,所以每个一样的图出现了三次,你要放置不一样的图片,就不会出现该问题了。

源代码

from PIL import Image
import osmap = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1],[1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1],[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],[1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
]# 这个是我图片的所在路径
img_dir = "photo"imgs = os.listdir(img_dir)
img_h = img_w = 192
rows = len(map)
columns = len(map[0])
figure = Image.new("RGB", (img_w * columns, img_h * rows), "white")count = 0
for i in range(len(map)):for j in range(len(map[i])):if map[i][j] == 1:continueelse:try:image = Image.open(os.path.join(img_dir, imgs[count]))except:continueimage = image.resize((img_w, img_h))figure.paste(image, (img_w * j, img_h * i))count += 1figure.show()
figure.save('心型照片墙.png')

8、电脑弹框表白

成品展示

源代码

import tkinter as tk
import random
import threading
import timedef dow():window = tk.Tk()width = window.winfo_screenwidth()height = window.winfo_screenheight()a = random.randrange(0, width)b = random.randrange(0, height)window.title('520快乐')window.geometry("200x50" + "+" + str(a) + "+" + str(b))tk.Label(window,text='520快乐!爱你幺',bg='Red',  # 背景颜色font=('楷体', 17),width=15, height=2).pack()window.mainloop()threads = []
for i in range(30):  # 需要的弹框数量,别写太多,容易电脑卡死哦t = threading.Thread(target=dow)threads.append(t)time.sleep(0.1)threads[i].start()

9、字符画-用字画你女朋友

成品展示

原图:

渲染之后的图:

源代码

剩余内容请转至VX公众号 “运维家” ,回复 “166” 查看。

------ “运维家” ,回复 “166” ------
------ “运维家” ,回复 “166” ------
------ “运维家” ,回复 “166” ------

重庆安全运维工程师入行门槛低,运维监理工程师是做什么的,大连找工作运维工程师,系统运维工程师工作计划的编写,系统运维工程师学习课程,适合运维工程师的兼职,信息运维工程师绩效考核表,高级运维工程师薪资待遇,风电运维工程师连体工作服,运维工程师的sql面试题,it运维工程师问题,运维工程师应具备什么技能,运维工程师列常检测什么,国投电力初级运维工程师,运维工程师日常照片,华北电力运维工程师是做什么的,网络工程师辛苦吗电商运维工作,电气工程师运维月薪,运维工程师百度,运维工程师相关的书。

python-520表白代码,我看谁说程序员不懂浪漫,送你几套表白代码,一步到位相关推荐

  1. python代码情话_谁说程序员不懂浪漫?代码情书专门为你定制

    今天是520,被很多人称为网络情人节. 说来也怪,从谈恋爱到结婚,每逢情人节前的那个深夜,我都会被沉重的压力折腾的无法入眠. 为什么?因为不知道送什么礼物,不知道用什么样的甜言蜜语才能更有创意. 不是 ...

  2. python软件是免费的吗-谁说程序员不懂浪漫?用Python每天自动给女朋友免费发短信...

    前言 之前发过一篇文章,用 Python 制作的给父母天气预报提醒的小工具天气变冷了,给父母制作一个天气提醒小助手,这篇文章我同步到博客上之后,有读者在评论区留言,对于部分微信没有网页版接口,导致无法 ...

  3. python 人像素描_谁说程序员不懂浪漫的,直接用 Python 给女朋友画张素描

    现在总有人说什么程序员不够浪漫!天真,你以为是真的不够浪漫吗? 其实我们只是没时间而已,每天都这么忙,不是开发程序就是修bug,都要聪明绝顶了, 哪还有精力搞浪漫,不过,等我们有时间了,那就没有你们普 ...

  4. 都说程序员不懂浪漫,看完这些你get到了吗?

    第一条:直到死之前,每天爱你多一点 while (life < end) {love++; } 复制代码 第二条:I can not say Hello to the World without ...

  5. 程序员最浪漫情话:等我敲完代码,就和你离婚!

    程序员往往城还没攻下来,我们的头发就先掉下来! 程序员最浪漫情话: 段子一 "等我敲完这行代码,就和你离婚!" 他头也不抬的说 听完之后,她心里暖暖的 她想,这可能是最长情的承诺. ...

  6. 试看5分钟视频python_不会Python吗?几分钟看完资深程序员给你的Python入门指南...

    python作为目前一门非常火爆的编程语言,其强大的功能吸引了众多学习者.但是针对那些没有任何编程经验,从零开始学习 Python 的同学.究竟怎么入门成了大家关心的问题,虽然网络上有众多python ...

  7. 必须用Python给程序员不懂浪漫平反一波....不管班花还是校花全都跑不掉~

    前言 今天是来给我们程序员平反来的,不能光自黑了,这一套下来不管是班花还是消化通通拿下,你信不信?反正我信了 PS:另外我问一下大家这波能不能让辣条哥彻底的装一波,可以的话三连"666&qu ...

  8. 用Python每天自动给女朋友免费发短信,谁说程序员不懂浪漫?

    前言 之前发过一篇文章,用 Python 制作的给父母天气预报提醒的小工具天气变冷了,给父母制作一个天气提醒小助手,这篇文章我同步到博客上之后,有读者在评论区留言,对于部分微信没有网页版接口,导致无法 ...

  9. 谁说程序员不懂浪漫?用Python每天自动给女朋友免费发短信

    前言 之前发过一篇文章,用 Python 制作的给父母天气预报提醒的小工具天气变冷了,给父母制作一个天气提醒小助手,这篇文章我同步到博客上之后,有读者在评论区留言,对于部分微信没有网页版接口,导致无法 ...

最新文章

  1. C++ string类中的find()函数的简单使用
  2. display:inline、block、inline-block的区别
  3. HashMap 的使用
  4. Mahout学习路线图
  5. redis setnx 过期时间_阿里面试官:你确定你用过 Redis 分布式锁吗?
  6. 01Prism WPF 入门实战 - 项目准备
  7. 【原】移动web页面兼容处理的思考
  8. Winform界面中实现菜单列表的动态个性化配置管理
  9. FISCO BCOS 区块链交易流程 区块
  10. anaconda自带的python是什么版本_anaconda怎么查看python版本
  11. 摄像模组中光学相关知识(四)
  12. 软件开发流程:需求评审流程
  13. 使用rmmod无法卸载驱动,强制卸除的两种方法
  14. [渝粤教育] 南京审计大学 审计学基础 参考 资料
  15. 【高等数学笔记】曲面积分的计算
  16. redis内存回收——过期、淘汰
  17. 1-MATLAB APP Design-图像的输入与输出
  18. 骞云科技SmartCMP v3.5版本正式发布
  19. php开启端口复用,WebServer端口复用后门
  20. 英菲尼迪tlme是什么意思_Infiniti是什么意思

热门文章

  1. temporal shift module(TSM)
  2. vue初始化项目出现unable to access ‘https://github.com/nhn/raphael.git/’解决有效 2021-12-30
  3. C# StreamReader/StreamWriter类
  4. jta mysql_JTA事务
  5. 不确定性:人类的现状,未来,过去,特质,在宇宙中的位置,道德与良知
  6. 【奈茶君】ESP32S3 IDF RMT驱动WS2812
  7. C++ setfill-没有与这些操作数相匹配的运算符
  8. 浅谈一下公司创业类型和一点点创业心得
  9. 医院里的超硬核“人体模型”指路牌火了!网友被吓哭,医生回应
  10. python编写一个登陆验证程序_Python实现简单登录验证详解