python写爱心代码(七夕快到了,你怎么还不向我表白?)

wufei123 发布于 2024-09-19 阅读(10)

点击上方头像关注我,每周上午 09:00准时推送,每月不定期赠送技术书籍,小窗口回复“资源”、“测试工具包”领取测试资源本文4202字,阅读约需11分钟Hi,大家好只有把整年的日历翻开,才会猛然发现:哇!每个月都有一个不同主题的情人节。

从1月14日的“日记情人节”到12月14日的“拥抱情人节”主题虽不同,但弥漫的甜蜜都一样正如莎士比亚曾所说:爱叫懦夫变得大胆,却叫勇士变得懦夫但常常有人还没尝到爱的滋味,就已变成了懦夫七夕马上就要到来,希望你能借着“情人节”的契机,把自己变成勇士,大胆去表白。

万一成功了呢?一Python实现素描像表白准备条件① 安装pycharm② 安装Python③ 找个男/女朋友准备好女/男朋友照片情侣照骗已经准备好了,如下:

Python代码实现素描效果

运行之后,实现效果如下:

二Python实现手绘爱心表白准备条件① 安装pycharm② 安装PythonPython代码实现手绘爱心实现代码如下:# ITester软件测试小栈 fromturtleimport * defgo_to

(x, y): up() goto(x, y) down() defbig_Circle(size): # 函数用于绘制心的大圆 speed(1) foriin

range(150): forward(size) right(0.3) defsmall_Circle(size): # 函数用于绘制心的小圆 speed(1

) foriinrange(210): forward(size) right(0.786) defline(size): speed(1) forward

(51 * size) defheart(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() defarrow(): pensize(10) setheading(0) go_to(-400, 0) left(15) forward(

150) go_to(339, 178) forward(150) defarrowHead(): pensize(1) speed(1) color(red,

red) begin_fill() left(120) forward(20) right(150) forward(35) right(120)

forward(35) right(150) forward(20) end_fill() defmain(): pensize(2) color(red, pink

) # getscreen().tracer(30, 0) #取消注释后,快速显示图案 heart(200, 0, 1) # 画出第一颗心,前面两个参数控制心的位置,函数最后一个参数可控制心的大小

setheading(0) # 使画笔的方向朝向x轴正方向 heart(-80, -100, 1.5) # 画出第二颗心 arrow() # 画出穿过两颗心的直线 arrowHead

() # 画出箭的箭头 go_to(400, -300) write("author:ITester", move=True, align="left", font=("宋体", 30

, "normal")) done() main()运行之后,就实现了动态手绘爱心的效果啦。

三Python实现表白程序准备条件① 安装pycharm② 安装Python③ 一张背景图Python实现表白程序代码实现如下:# ITester软件测试小栈from tkinter import *

from PIL import Image ,ImageTk import tkinter import tkinter.messagebox root=Tk() root.title(小姐姐,我要向你表白!

) root.geometry("600x500+300+100") cv= Canvas(root, width = 600, height =500, bg = "white") cv.pack() image = Image.open(

love.png) im = ImageTk.PhotoImage(image) cv.create_image(270,190,image = im) defoppose(): tkinter.messagebox.showinfo(title=

扎心了!, message=再考虑考虑吧,不要急着回答) defagree(): tkinter.messagebox.showinfo( title="欧耶", message="我不同意咯!"

) tkinter.messagebox.showinfo( title="欧耶", message="别再打扰我了!") root.destroy() defhesitate(): tkinter.messagebox.showinfo(title=

别纠结了, message=你完了,你妈让你嫁给我) tkinter.messagebox.showinfo(title=别纠结了, message=你爸也是这么说的) tkinter.messagebox.showinfo(title=

别纠结了, message=你奶奶也让你嫁给我) tkinter.messagebox.showinfo(title=别纠结了, message=你哥哥也同意了) tkinter.messagebox.showinfo(title=

别纠结了, message=你闺蜜说嫁给我没错) tkinter.messagebox.showinfo(title=别纠结了, message=你爸说不同意就打你) tkinter.messagebox.showinfo(title=

别纠结了, message=掉水我先救你) tkinter.messagebox.showinfo(title=别纠结了, message=孩子难产我保大) tkinter.messagebox.showinfo(title=

别纠结了, message=银行卡都给你) tkinter.messagebox.showinfo(title=别纠结了, message=接受现实吧,我会对你好的) defcloseWindow

(): tkinter.messagebox.showerror(title=未作回应,message=小姐姐,请不要逃避!) returnFalse root.protocol(WM_DELETE_WINDOW

, closeWindow) output_label0 = Label(root,text ="实话告诉你吧", font =("仿宋", 16,"bold")) cv.create_window(20

, 20, anchor=NW, window= output_label0) output_label1 = Label(root,text ="我喜欢你很久了", font =("仿宋", 16,"bold"

)) cv.create_window(40, 70, anchor=NW, window= output_label1) output_label2 = Label(root,text ="你看着办吧"

, font =("仿宋", 16,"bold")) cv.create_window(50, 110, anchor=NW, window= output_label2) Button1 = Button(root, text=

"同意", font =("仿宋", 16,"bold"),width=10,height=1,command = agree) cv.create_window(110, 430, anchor=NW, window=Button1) Button2 = Button(root,text=

考虑一下, font =("仿宋", 16,"bold"),width=10,height=1,command = hesitate ) cv.create_window(260, 430, anchor=NW, window=Button2) Button3 = Button(root,text=

不同意, font =("仿宋", 16,"bold"),width=10,height=1,command = oppose) cv.create_window(450, 430, anchor=NW, window=Button3) root.mainloop()

运行代码,实现效果如下图:

最后,祝天下有情人终成眷属,七夕快乐!❤️更多系列文章敬请期待我是CoCo,计算机科学与技术专业,深漂大厂互联网民工(女),坐标深圳5年工作经验,3年持续输出技术文ITester软件测试小栈(ID:ITestingA),专注于软件测试技术和宝藏干货分享,每周准时更新原创技术文章,每月不定期赠送技术书籍,愿我们在更高处相逢。

喜欢记得星标⭐我,每周及时获得最新推送,第三方转载请注明出处

想获取更多最新干货内容快来星标 置顶 关注我

亲爱的读者们,感谢您花时间阅读本文。如果您对本文有任何疑问或建议,请随时联系我。我非常乐意与您交流。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。