七夕的简易代码表白合集 您所在的位置:网站首页 七夕表白代码Java 七夕的简易代码表白合集

七夕的简易代码表白合集

2023-09-13 03:02| 来源: 网络整理| 查看: 265

一个小小的提问?

今天是2022年的8月2日,距离七夕只剩下俩天。作为程序员群体中的一员,你们准备好了吗?

话题:

每个人在人生的旅途中总会被在不经意间贴上了特定的标签。医生:救死扶伤;警察:英勇无畏;学者:满腹经纶。那么属于程序员的标签又是什么呢?我想很多人的第一印象——低情商。我们在生活中不懂得使用浪漫的情话,日常琐碎和柴米油盐占据了生活的意义。面对这样的标签,我们应该如何面对,又如何改变?不如在2022年的8月4日尝试一下你最新的浪漫。

代码合集:

代码小白的我为大家收集了简易的多种表白代码提供大家参考。因实力和时间有限,本次合集代码均为转载,非个人原创代码,敬请谅解。(解释器:Pycharm)

爱心代码

比心——日常生活中我们表达喜欢的最常用的动作。那么爱心的展现是不是可以让我们所爱的人清楚的感受到我们对他(她)的爱意呢。

import random import turtle from turtle import mainloop, hideturtle # 画心 def draw_heart(size, color_): turtle.speed(0) turtle.colormode(255) turtle.color(color_) turtle.pensize(2) turtle.pendown() turtle.setheading(150) turtle.begin_fill() turtle.fd(size) turtle.circle(size * -3.745, 45) turtle.circle(size * -1.431, 165) turtle.left(120) turtle.circle(size * -1.431, 165) turtle.circle(size * -3.745, 45) turtle.fd(size) turtle.end_fill() # 随机颜色,大小,位置 def draw(): # 随机颜色 colors1 = random.randint(0, 255) colors2 = random.randint(0, 255) colors3 = random.randint(0, 255) turtle.penup() # 随机位置 x = random.randint(-400, 400) y = random.randint(-200, 200) turtle.goto(x, y) # 随机大小 size = random.randint(10, 20) draw_heart(size, (colors1, colors2, colors3)) # 主函数 def main(): hideturtle() turtle.setup(900, 500) # 更改心出现的个数 for i in range(30): draw() turtle.penup() turtle.goto(-200, 0) turtle.color('red') turtle.write('爱你哦', font=('宋体', 60, 'normal')) mainloop() main()

效果展示:

爱心发射

满屏的爱心彰显青春的浪漫,爱心发射共谱爱的乐章。

import turtle import time from turtle import mainloop, hideturtle def clear_all(): turtle.penup() turtle.goto(0, 0) turtle.color('white') turtle.pensize(800) turtle.pendown() turtle.setheading(0) turtle.fd(300) turtle.bk(600) # 重定位海龟的位置 def go_to(x, y, state): turtle.pendown() if state else turtle.penup() turtle.goto(x, y) def draw_heart(size): turtle.color('red', 'pink') turtle.pensize(2) turtle.pendown() turtle.setheading(150) turtle.begin_fill() turtle.fd(size) turtle.circle(size * -3.745, 45) turtle.circle(size * -1.431, 165) turtle.left(120) turtle.circle(size * -1.431, 165) turtle.circle(size * -3.745, 45) turtle.fd(size) turtle.end_fill() # 画出发射爱心的小人 def draw_people(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.pensize(2) turtle.color('black') turtle.setheading(0) turtle.circle(60, 360) turtle.penup() turtle.setheading(90) turtle.fd(75) turtle.setheading(180) turtle.fd(20) turtle.pensize(4) turtle.pendown() turtle.circle(2, 360) turtle.setheading(0) turtle.penup() turtle.fd(40) turtle.pensize(4) turtle.pendown() turtle.circle(-2, 360) turtle.penup() turtle.goto(x, y) turtle.setheading(-90) turtle.pendown() turtle.fd(20) turtle.setheading(0) turtle.fd(35) turtle.setheading(60) turtle.fd(10) turtle.penup() turtle.goto(x, y) turtle.setheading(-90) turtle.pendown() turtle.fd(40) turtle.setheading(0) turtle.fd(35) turtle.setheading(-60) turtle.fd(10) turtle.penup() turtle.goto(x, y) turtle.setheading(-90) turtle.pendown() turtle.fd(60) turtle.setheading(-135) turtle.fd(60) turtle.bk(60) turtle.setheading(-45) turtle.fd(30) turtle.setheading(-135) turtle.fd(35) turtle.penup() # 绘制文字 def draw_text(text, t_color, font_size, show_time): turtle.penup() turtle.goto(-350, 0) turtle.color(t_color) turtle.write(text, font=('宋体', font_size, 'normal')) time.sleep(show_time) clear_all() # 爱心发射 def draw_(): turtle.speed(0) draw_people(-250, 20) turtle.penup() turtle.goto(-150, -30) draw_heart(14) turtle.penup() turtle.goto(-200, -200) turtle.color('pink') turtle.write('爱', font=('宋体', 60, 'normal')) turtle.penup() turtle.goto(-20, -60) draw_heart(25) turtle.penup() turtle.goto(-70, -200) turtle.color('pink') turtle.write('你', font=('宋体', 60, 'normal')) turtle.penup() turtle.goto(200, -100) draw_heart(45) turtle.penup() turtle.goto(150, -200) turtle.color('pink') turtle.write('哟', font=('宋体', 60, 'normal')) turtle.hideturtle() time.sleep(3) def main(): # 隐藏海龟 hideturtle() turtle.setup(900, 500) draw_text("准备好了吗?", "black", 60, 0) draw_text("接下来", "skyblue", 60, 0) draw_text("马上七夕,码上七夕", "pink", 60, 3) draw_() # 使用mainloop防止窗口卡死 mainloop() main()

效果展示:

 爱的弹窗

相较于爱心的直白,不少同学喜欢使用弹窗式的恩爱。

import tkinter as tk import threading import time import random def dow(): window = tk.Tk() width = window.winfo_screenwidth() height = window.winfo_screenheight() a = random.randrange(0,width) b = random.randrange(0,height) window.title("爱的表白") window.geometry("200x50"+"+"+str(a)+"+"+str(b)) tk.Label(window,text='亲爱的,七夕节快乐!',bg='pink',fg='white',font=('楷体',14,),width=20,height=2).pack() window.mainloop() threads=[] for i in range(100): t = threading.Thread(target=dow) threads.append(t) time.sleep(0.1) threads[i].start()

效果展示:

满屏的情话,就好像主权的宣誓。

祝福:

  古有仙女斗巧,今有程序表白。在爱情的世界,我祝愿大家不是荒芜而是乐园。

代码引用来源:

 爱心代码、爱心发射:“二哥不像程序员” 的博文。链接地址:❤️马上七夕,不懂浪漫?带你用Python“码”上七夕【建议收藏】❤️_二哥不像程序员的博客-CSDN博客

爱的弹窗 :“茶哩”的博文。链接地址:python实现七夕祝福语_茶哩的博客-CSDN博客



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有