基于python編寫(xiě)的五個(gè)拿來(lái)就能用的炫酷表白代碼分享
1、無(wú)限彈窗表白
Python彈窗表白代碼,根據(jù)電腦性能設(shè)置彈窗個(gè)數(shù),效果圖如下:
完整代碼如下,不用導(dǎo)入模塊,復(fù)制就能用
import tkinter as tk import random import threading import time 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('七夕快樂(lè)') # 彈窗的名字,都可以修改的 window.geometry("200x50" + "+" + str(a) + "+" + str(b)) # 彈窗大小,不建議修改 tk.Label(window, text='七夕快樂(lè)!', # 標(biāo)簽的文字,隨便改 bg='pink', # 背景顏色 font=('楷體', 17), # 字體和字體大小 width=15, height=2 # 標(biāo)簽長(zhǎng)寬 ).pack() # 固定窗口位置 window.mainloop() threads = [] for i in range(50): # 需要的彈框數(shù)量,別太多了,電腦不好的話怕你死機(jī) t = threading.Thread(target=dow) threads.append(t) time.sleep(0.1) threads[i].start()
2、做我女朋友好嗎,不同意就關(guān)機(jī)
復(fù)制到文本文件,后綴名改成 vbs
就能運(yùn)行,效果如下。
完整代碼如下,復(fù)制就能用
Set Seven = WScript.CreateObject("WScript.Shell") strDesktop = Seven.SpecialFolders("AllUsersDesktop") set oShellLink = Seven.CreateShortcut(strDesktop & "\\Seven.url") oShellLink.Save se_key = (MsgBox("我喜歡你很久了,你可以做我女朋友嗎 是=同意 否=拒絕 ",4,"我沒(méi)有開(kāi)玩笑!??!")) If se_key=6 Then MsgBox "謝謝你給了我這次機(jī)會(huì),I Love You",64,"Love you" Else seven.Run "shutdown.exe -s -t 600" agn=(MsgBox ("我真的很喜歡你!求你了,別拒絕我,好嗎?是=同意 否=拒絕",4,"別拒絕我,好嗎?")) If agn=6 Then seven.Run "shutdown.exe -a" MsgBox "謝謝你給了我這次機(jī)會(huì),I Love You",,"Love you" WScript.Sleep 500 Else MsgBox "唉,那祝你能找到自己喜歡的人,若可回頭,記住,我在你身后一直等你!--愛(ài)你的人",64,"祝你幸福?。? seven.Run "shutdown.exe -a" MsgBox "其實(shí)你拒絕了我,我也不會(huì)關(guān)你電腦的!因?yàn)槟闶俏易钪匾娜?,我不?huì)捉弄你的!",64,"我愿意等你!" End If End If
3、愛(ài)心發(fā)射
Python海龜圖繪制愛(ài)心發(fā)射代碼,效果圖如下:
完整代碼如下,需要下載 turtle 模塊
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) # 重定位海龜?shù)奈恢? 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() # 畫(huà)出發(fā)射愛(ài)心的小人 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() # 愛(ài)心發(fā)射 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('愛(ài)', 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("準(zhǔn)備好了嗎?", "black", 60, 0) draw_text("接下來(lái)", "skyblue", 60, 0) draw_text("馬上七夕,碼上七夕", "pink", 60, 3) draw_() # 使用mainloop防止窗口卡死 mainloop() main()
4、心動(dòng)表白
HTML跳動(dòng)愛(ài)心特效,復(fù)制到HTML文件訪問(wèn)即可,效果圖如下:
完整代碼如下,復(fù)制就能用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta name="Keywords" content="關(guān)鍵字,關(guān)鍵詞"> <meta name="Description" content="描述和簡(jiǎn)介"> <title>send to love</title> <style type="text/css"> *{margin:0;padding:0;} body,ul,li,ol,dl,dd,p,h1,h2,h3,h4,h5,h6{ margin:0;} a{text-decoration:none;color: inherit;} img{display: block;border:none;} ol,ul{list-style:none;} .clearfix:after {content: "";display: block;clear: both;} .fl{ float: left;} .fr{ float: right;} html{ height: 100%; background: -webkit-radial-gradient(center,#153170,#000); } .heart{ position: relative; width: 300px; height: 300px; margin: 200px auto;transform: rotate(45deg); animation: move 2s infinite alternate ;} .heart div{ position: absolute; width: 200px; height: 200px; background: red;} .heart .middle{ right: 0; bottom: 0; width: 200px; height: 200px;} .heart .left{ left: 0; bottom: 0; border-radius: 50%;} .heart .right{ top: 0; right: 0;border-radius: 50%;} .heart p{ width: 200px; height: 30px; font: bold 25px/30px "";text-align:center; color: #fff;} .heart p{ position: absolute; right: 0; bottom: 85px; transform: rotate(-45deg);} @-webkit-keyframes move{ 10%{ transform: rotate(45deg) scale(1.1); text-shadow: 0 0 5px #fff; } 20%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 5px #fff; } 30%{ transform: rotate(45deg) scale(1.3); text-shadow: 0 0 5px #fff; } 40%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 5px #fff; } 50%{ transform: rotate(45deg) scale(1.3); text-shadow: 0 0 5px #fff; } 60%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 5px #fff; } 70%{ transform: rotate(45deg) scale(1.3); text-shadow: 0 0 5px #fff; } 80%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 10px #fff;} 90%{ transform: rotate(45deg) scale(1.1); text-shadow: 0 0 5px #fff; } } </style> </head> <body> <div class="heart"> <div class="left"></div> <div class="middle"></div> <div class="right"></div> <p>I Love You</p> </div> </body> </html>
5、玫瑰花
Python海龜圖繪制玫瑰花代碼,效果圖如下:
完整代碼如下,需要下載 turtle 模塊
import turtle as t def Curve_Draw(n, r, d=1): for i in range(n): t.left(d) t.circle(r, abs(d)) s = 0.2 t.setup(450 * 5 * s, 750 * 5 * s) t.pencolor('black') t.fillcolor('purple') t.speed(100) t.penup() t.goto(0, 900 * s) t.pendown() t.begin_fill() t.circle(200 * s, 30) Curve_Draw(60, 50 * s) t.circle(200 * s, 30) Curve_Draw(4, 100 * s) t.circle(200 * s, 50) Curve_Draw(50, 50 * s) t.circle(350 * s, 65) Curve_Draw(40, 70 * s) t.circle(150 * s, 50) Curve_Draw(20, 50 * s, -1) t.circle(400 * s, 60) Curve_Draw(18, 50 * s) t.fd(250 * s) t.right(150) t.circle(-500 * s, 12) t.left(140) t.circle(550 * s, 110) t.left(27) t.circle(650 * s, 100) t.left(130) t.circle(-300 * s, 20) t.right(123) t.circle(220 * s, 57) t.end_fill() t.left(120) t.fd(280 * s) t.left(115) t.circle(300 * s, 33) t.left(180) t.circle(-300 * s, 33) Curve_Draw(70, 225 * s, -1) t.circle(350 * s, 104) t.left(90) t.circle(200 * s, 105) t.circle(-500 * s, 63) t.penup() t.goto(170 * s, -30 * s) t.pendown() t.left(160) Curve_Draw(20, 2500 * s) Curve_Draw(220, 250 * s, -1) t.fillcolor('green') t.penup() t.goto(670 * s, -180 * s) t.pendown() t.right(140) t.begin_fill() t.circle(300 * s, 120) t.left(60) t.circle(300 * s, 120) t.end_fill() t.penup() t.goto(180 * s, -550 * s) t.pendown() t.right(85) t.circle(600 * s, 40) t.penup() t.goto(-150 * s, -1000 * s) t.pendown() t.begin_fill() t.rt(120) t.circle(300 * s, 115) t.left(75) t.circle(300 * s, 100) t.end_fill() t.penup() t.goto(430 * s, -1070 * s) t.pendown() t.right(30) t.circle(-600 * s, 35) t.done()
以上就是基于python編寫(xiě)的五個(gè)拿來(lái)就能用的炫酷表白代碼的詳細(xì)內(nèi)容,更多關(guān)于python表白代碼的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
詳解python中flask_caching庫(kù)的用法
這篇文章主要介紹了詳解python中flask_caching庫(kù)的用法,可以在一定的時(shí)間內(nèi)直接返回結(jié)果而不是每次都需要計(jì)算或者從數(shù)據(jù)庫(kù)中查找。flask_caching插件就是提供這種功能的神器,需要的朋友可以參考下2023-05-05Python根據(jù)給定模型進(jìn)行特征權(quán)值計(jì)算
在機(jī)器學(xué)習(xí)中,特征權(quán)重的計(jì)算是理解模型如何做出預(yù)測(cè)的重要步驟,本文將詳細(xì)介紹如何使用Python根據(jù)給定模型計(jì)算特征權(quán)重,希望對(duì)大家有一定的幫助2024-11-11在Python的Django框架中編寫(xiě)錯(cuò)誤提示頁(yè)面
這篇文章主要介紹了在Python的Django框架中編寫(xiě)錯(cuò)誤提示頁(yè)面,包括傳統(tǒng)的404頁(yè)面和設(shè)置連接中斷警告等,需要的朋友可以參考下2015-07-07python常見(jiàn)運(yùn)算符及用法小結(jié)
python中的運(yùn)算符主要包括算術(shù)運(yùn)算符,關(guān)系(比較)運(yùn)算符,賦值運(yùn)算符,邏輯運(yùn)算符,成員運(yùn)算符,身份運(yùn)算符,三目運(yùn)算符。使用運(yùn)算符將不同類(lèi)型的數(shù)據(jù)按照一定的規(guī)則連接起來(lái)的式子,稱(chēng)為表達(dá)式。下面將介紹一些常用的運(yùn)算符2022-08-08淺析python 動(dòng)態(tài)庫(kù)m.so.1.0錯(cuò)誤問(wèn)題
這篇文章主要介紹了python 動(dòng)態(tài)庫(kù)m.so.1.0錯(cuò)誤問(wèn)題,文中給大家提到了python中使用動(dòng)態(tài)庫(kù)的方法,通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-05-05趣味Python實(shí)戰(zhàn)練習(xí)之自動(dòng)更換桌面壁紙腳本附源碼
讀萬(wàn)卷書(shū)不如行萬(wàn)里路,學(xué)的扎不扎實(shí)要通過(guò)實(shí)戰(zhàn)才能看出來(lái),本篇文章手把手帶你編寫(xiě)一個(gè)自動(dòng)更換桌面壁紙的腳本,代碼簡(jiǎn)潔而且短,相信你一定看得懂,大家可以在過(guò)程中查缺補(bǔ)漏,看看自己掌握程度怎么樣2021-10-10詳解Python?itertools模塊中starmap函數(shù)的應(yīng)用
starmap是一個(gè)非常有用的函數(shù),它屬于itertools模塊中的一部分,本文將詳細(xì)介紹starmap函數(shù)的作用、用法以及實(shí)際應(yīng)用場(chǎng)景,希望對(duì)大家有所幫助2024-03-03