❶ python-520表白代碼,我看誰說程序員不懂浪漫,送你幾套表白代碼,一步到位
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 turtleimport 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 Timport randomimport 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 Imageimport 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 = 192rows = len(map)columns = len(map[0])figure = Image.new("RGB", (img_w * columns, img_h * rows), "white")count = 0for 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 tkimport randomimport threadingimport 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(驠快樂')window.geometry("200x50" + "+" + str(a) + "+" + str(b))tk.Label(window, text=驠快樂!愛你幺', 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」 ?------
重慶安全運維工程師入行門檻低,運維監理工程師是做什麼的,大連找工作運維工程師,系統運維工程師工作計劃的編寫,系統運維工程師學習課程,適合運維工程師的兼職,信息運維工