情人节表白(持续更新,欢迎收藏)

1、抖音同款,不同意不许走

源码:love.py

 1 # coding: utf8
 2 from tkinter import *
 3 from tkinter import messagebox
 4 import random
 5 
 6 def no_close():
 7     return
 8 
 9 #关闭所有窗口
10 def close_all_window():
11     window.destroy()
12 
13 #关闭窗口提示
14 def close_window():
15     messagebox.showinfo(title="不要嘛~", message="不选好不许走!")
16 
17 #“好的”窗口
18 def Love():
19     love = Toplevel(window)
20     love.geometry("300x100+580+250")
21     love.title("爱你么么哒~")
22     btn = Button(love, text="在一起!", width=10, height=2, command=close_all_window)
23     btn.place(x=100, y=30)
24     love.protocol("WM_DELETE_WINDOW", no_close)
25 
26 window = Tk()
27 window.title("嗨,小姐姐") #窗口标题
28 window.geometry("360x640+550+50") #窗口大小
29 window.protocol("WM_DELETE_WINDOW", close_window) #窗口关闭
30 label = Label(window, text="观察你很久了", font=("微软雅黑", 18))
31 label.place(x=120, y=50)
32 label = Label(window, text="做我女朋友好不好?", font=("微软雅黑", 24))
33 label.place(x=70, y=100)
34 btn1 = Button(window, text="", width=15, height=2, command=Love)
35 btn1.place(x=110, y=200)
36 # “不好”按钮
37 pos = [110, 300]
38 btn2 = Button(window, text="不好", width=15, height=2)
39 btn2.place(x=pos[0], y=pos[1])
40 def on_enter(e):
41     global pos
42     dx = random.randint(100, 200)
43     dy = random.randint(100, 300)
44     print(pos,dx,dy)
45     pos = (pos[0] + dx) % 200, (pos[1] - 250 + dy) % 350 + 250
46     btn2.place(x=pos[0], y=pos[1])
47 btn2.bind("<Enter>", on_enter)
48 
49 #显示窗口,消息循坏
50 window.mainloop()

 

运行效果:
在这里插入图片描述

2、阿狸桃子爱情表白

文件有点大,截图不方便,需要全部文件及源码私信。
源码:love.html

  1 <!DOCTYPE html>
  2 <!--[if IE 6]>
  3 <html id="ie6" class="ie ie6 lt-ie9">
  4 <![endif]-->
  5 <!--[if IE 7]>
  6 <html id="ie7" class="ie ie7 lt-ie9">
  7 <![endif]-->
  8 <!--[if IE 8]>
  9 <html id="ie8" class="ie ie8 lt-ie9">
 10 <![endif]-->
 11 <!--[if gte IE 9]>
 12 <html class="ie ie9">
 13 <![endif]-->
 14 <!--[if !(IE)]><!-->
 15 <html><!--<![endif]--><head>
 16 <title>我们的回忆</title>
 17 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
 18     <meta http-equiv="Pragma" content="no-cache">
 19     <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
 20     <link rel="stylesheet" href="love2/all.css" tppabs="love2/all.min.css">
 21 
 22 </head>
 23 <body class="ft-absolute-nav">
 24     <div style="transform: translateX(0%) translateY(0%);" class="flowtime no-transition">
 25         <div id="" data-prog="__1" class="ft-section section-1" data-id="__section-1">
 26             <div data-prog="__1" id="" class="ft-page page-1 hilite actual" data-id="__page-1">
 27                 <p class="text1"><span id="text-75" contenteditable="true"></span><span id="text-76" contenteditable="true"></span> <span id="text-77" contenteditable="true">一生一世</span></p>
 28                 <p class="text2">按键盘 "↓" <span id="text-78" contenteditable="true">开始倾听我的表白</span></p>
 29             </div>
 30             <div data-prog="__2" id="" class="ft-page page-2 future-page" data-id="__page-2">
 31                 <p class="top-text" id="text-1" contenteditable="true">过去的他一直是一个人生活,享受着孤独,也憧憬着爱情。</p>
 32                 <img src="love2/iali63.jpg" alt="过去的小明一直是一个人生活,享受着孤独,也憧憬着爱情。">
 33             </div>
 34             <div data-prog="__3" id="" class="ft-page page-3 left-img future-page" data-id="__page-3">
 35                 <h2 class="text" id="text-2" contenteditable="true">一个人的长廊</h2>
 36                 <img src="love2/iali35.jpg" alt="一个人的长廊">
 37             </div>
 38             <div data-prog="__4" id="" class="ft-page page-4 full-img future-page" data-id="__page-4">
 39                 <h2 class="center-text" id="text-3" contenteditable="true">一个人的山岗</h2>
 40                 <img src="love2/iali6.jpg" alt="一个人的山岗">
 41             </div>
 42         </div>
 43         <div id="" data-prog="__2" class="ft-section section-2" data-id="__section-2">
 44             <div data-prog="__1" id="" class="ft-page page-5 full-img future-section" data-id="__page-1">
 45                 <h2 class="center-text" id="text-4" contenteditable="true">一个人的地铁</h2>
 46                 <img src="love2/iali19.jpg" alt="一个人的地铁">
 47             </div>
 48             <div data-prog="__2" id="" class="ft-page page-6 future-section future-page" data-id="__page-2">
 49                 <h2 class="center-text" id="text-5" contenteditable="true">一个人的游乐场</h2>
 50                 <img src="love2/iali29.jpg" alt="一个人的游乐场">
 51             </div>
 52             <div data-prog="__3" id="" class="ft-page page-7 future-section future-page" data-id="__page-3">
 53                 <h3 id="text-6" contenteditable="true">但他依然乐观,微笑着,等待着</h3>
 54                 <img src="love2/iali60.jpg" alt="但他依然乐观,微笑着,等待着">
 55             </div>
 56             <div data-prog="__4" id="" class="ft-page page-8 full-img future-section future-page" data-id="__page-4">
 57                 <h3 id="text-7" contenteditable="true">生活难免有风风雨雨</h3>
 58                 <img src="love2/iali51.jpg" alt="生活难免有风风雨雨">
 59             </div>
 60             <div data-prog="__5" id="" class="ft-page page-9 future-section future-page" data-id="__page-5">
 61                 <h3 id="text-8" contenteditable="true">他总是能够轻松的应对</h3>
 62                 <img src="love2/iali5.jpg">
 63             </div>
 64             <div data-prog="__6" id="" class="ft-page page-10 future-section future-page" data-id="__page-6">
 65                 <h3 id="text-9" contenteditable="true">并且面带阳光、自信的笑容</h3>
 66                 <img src="love2/iali22.jpg">
 67             </div>
 68         </div>
 69         <div id="" data-prog="__3" class="ft-section section-3" data-id="__section-3">
 70             <div data-prog="__1" id="" class="ft-page page-11 full-img future-section" data-id="__page-1">
 71                 <h3 id="text-10" contenteditable="true">生活也不会总是一帆风顺</h3>
 72                 <img src="love2/iali24.jpg">
 73             </div>
 74             <div data-prog="__2" id="" class="ft-page page-12 future-section future-page" data-id="__page-2">
 75                 <h3><span id="text-11" contenteditable="true">但他每次都能勇敢的面对</span><br><span id="text-12" contenteditable="true">随时准备接受生活的挑战</span></h3>
 76                 <img src="love2/iali25.jpg">
 77             </div>
 78             <div data-prog="__3" id="" class="ft-page page-13 future-section future-page" data-id="__page-3">
 79                 <img src="love2/iali64.jpg" alt="可是小明的爱情又在哪里呢?">
 80                 <h3 id="text-13" contenteditable="true">可是他的爱情又在哪里呢?</h3>
 81             </div>
 82             <div data-prog="__4" id="" class="ft-page page-14 left-img future-section future-page" data-id="__page-4">
 83                 <h3 id="text-14" contenteditable="true">在镜子里面吗?他不敢相信</h3>
 84                 <img src="love2/iali46.jpg">
 85             </div>
 86             <div data-prog="__5" id="" class="ft-page page-15 left-img future-section future-page" data-id="__page-5">
 87                 <h3><span id="text-15" contenteditable="true">他去问大树,我的爱情在哪里?</span><br><span id="text-16" contenteditable="true">大树告诉他,也许就在不远的地方</span></h3>
 88                 <img src="love2/iali45.jpg">
 89             </div>
 90             <div data-prog="__6" id="" class="ft-page page-16 left-img future-section future-page" data-id="__page-6">
 91                 <h3><span id="text-17" contenteditable="true">于是,他一个人继续向前走</span><br><span id="text-18" contenteditable="true">走在茫茫的雪地上</span></h3>
 92                 <img src="love2/iali66.jpg">
 93             </div>
 94             <div data-prog="__7" id="" class="ft-page page-17 top-text future-section future-page" data-id="__page-7">
 95                 <h3 id="text-19" contenteditable="true">直到有一天他与她相遇了</h3>
 96                 <img src="love2/iali16.jpg">
 97             </div>
 98         </div>
 99         <div id="" data-prog="__4" class="ft-section section-4" data-id="__section-4">
100             <div data-prog="__1" id="" class="ft-page page-18 full-img future-section" data-id="__page-1">
101                 <p class="text" id="text-20" contenteditable="true">他喜欢她,因为她的出现,他脸上有了更加灿烂的笑容</p>
102                 <img src="love2/iali11.jpg">
103             </div>
104             <div data-prog="__2" id="" class="ft-page page-19 future-section future-page" data-id="__page-2">
105                 <h3 id="text-21" contenteditable="true">可是她会喜欢他吗?</h3>
106                 <img src="love2/iali75.jpg">
107             </div>
108             <div data-prog="__3" id="" class="ft-page page-20 future-section future-page" data-id="__page-3">
109                 <img src="love2/iali59.png" tppabs="http://kingzs70.oss.aliyuncs.com/iali/img/iali59.png">
110                 <h3 id="text-22" contenteditable="true">终于有一天,他鼓起了勇气</h3>
111                 <img src="love2/iali9.jpg">
112             </div>
113             <div data-prog="__4" id="" class="ft-page page-21 future-section future-page" data-id="__page-4">
114                 <h3 id="text-23" contenteditable="true">他好高兴</h3>
115                 <img src="love2/iali59_002.png">
116             </div>
117             <div data-prog="__5" id="" class="ft-page page-22 left-img future-section future-page" data-id="__page-5">
118                 <h3 id="text-24" contenteditable="true">每天他都会去找她</h3>
119                 <img src="love2/iali4.jpg">
120             </div>
121             <div data-prog="__6" id="" class="ft-page page-23 left-img future-section future-page" data-id="__page-6">
122                 <h3 id="text-25" contenteditable="true">然后两个人一起出去玩</h3>
123                 <img src="love2/iali44.jpg">
124             </div>
125             <div data-prog="__7" id="" class="ft-page page-24 full-img future-section future-page" data-id="__page-7">    
126                 <h3 id="text-26" contenteditable="true">晚上他会把她送回家</h3>
127                 <img src="love2/iali32.jpg">
128             </div>
129         </div>
130         <div id="" data-prog="__5" class="ft-section section-5" data-id="__section-5">
131             <div data-prog="__1" id="" class="ft-page page-25 left-img future-section" data-id="__page-1">
132                 <h3><span id="text-27" contenteditable="true">直到很晚</span><br><span id="text-28" contenteditable="true">他才会一个人回家</span></h3>
133                 <img src="love2/iali37.jpg">
134             </div>
135             <div data-prog="__2" id="" class="ft-page page-26 top-text future-section future-page" data-id="__page-2">
136                 <h3 id="text-29" contenteditable="true">然后高兴地进入梦乡,希望梦到她</h3>
137                 <img src="love2/iali10.gif">
138             </div>
139             <div data-prog="__3" id="" class="ft-page page-27 future-section future-page" data-id="__page-3">
140                 <h3 id="text-30" contenteditable="true">他很快就成为了她的逛街助手</h3>
141                 <img src="love2/iali67.jpg">
142             </div>
143             <div data-prog="__4" id="" class="ft-page page-28 future-section future-page" data-id="__page-4">
144                 <h3 id="text-31" contenteditable="true">他和她一起去了好多地方玩</h3>
145                 <img src="love2/iali40.jpg">
146             </div>
147             <div data-prog="__5" id="" class="ft-page page-29 future-section future-page" data-id="__page-5">
148                 <h3 id="text-32" contenteditable="true">他也和她一样成为了一个吃货</h3>
149                 <img src="love2/iali12.jpg">
150             </div>
151             <div data-prog="__6" id="" class="ft-page page-30 future-section future-page" data-id="__page-6">
152                 <h3 id="text-33" contenteditable="true">后来,他们搬到了一起</h3>
153                 <img src="love2/iali76.gif">
154             </div>
155             <div data-prog="__7" id="" class="ft-page page-31 future-section future-page" data-id="__page-7">
156                 <h3 id="text-34" contenteditable="true">于是他开始学习新的技能</h3>
157                 <img src="love2/iali77.jpg">
158             </div>
159         </div>
160         <div id="" data-prog="__6" class="ft-section section-6" data-id="__section-6">
161             <div data-prog="__1" id="" class="ft-page page-32 future-section" data-id="__page-1">
162                 <h3 id="text-35" contenteditable="true">煮饭</h3>
163                 <img src="love2/iali62.jpg">
164             </div>
165             <div data-prog="__2" id="" class="ft-page page-33 top-text future-section future-page" data-id="__page-2">
166                 <h3 id="text-36" contenteditable="true">每天早上,他们吃着自己做的美食</h3>
167                 <img src="love2/iali3.jpg">
168             </div>
169             <div data-prog="__3" id="" class="ft-page page-34 left-img future-section future-page" data-id="__page-3">
170                 <h3 id="text-37" contenteditable="true">然后在同一个站台,高高兴兴的一起上班</h3>
171             </div>
172             <div data-prog="__4" id="" class="ft-page page-35 future-section future-page" data-id="__page-4">
173                 <h3><span id="text-38" contenteditable="true">他感觉自己好幸福。</span><br><span id="text-39" contenteditable="true">因为自己有了家</span><br><span id="text-40" contenteditable="true">那个有她在的地方</span></h3>
174                 <img src="love2/iali8.gif">
175             </div>
176             <div data-prog="__5" id="" class="ft-page page-36 full-img future-section future-page" data-id="__page-5">
177                 <h3 id="text-41" contenteditable="true">他们偶尔也会吵架</h3>
178                 <img src="love2/iali31.jpg">
179             </div>
180             <div data-prog="__6" id="" class="ft-page page-37 left-img future-section future-page" data-id="__page-6">
181                 <h3 id="text-42" contenteditable="true">他不想这样</h3>
182                 <img src="love2/iali49.jpg">
183             </div>
184             <div data-prog="__7" id="" class="ft-page page-38 bottom-text future-section future-page" data-id="__page-7">
185                 <img src="love2/iali21.jpg">
186                 <h3 id="text-43" contenteditable="true">一定是我有什么做的不对,他在想</h3>
187             </div>
188         </div>
189         <div id="" data-prog="__7" class="ft-section section-7" data-id="__section-7">
190             <div data-prog="__1" id="" class="ft-page page-39 left-img future-section" data-id="__page-1">
191                 <h3 id="text-44" contenteditable="true">如果没有她在身边,窗外就没有风景</h3>
192                 <img src="love2/iali2.jpg">
193             </div>
194             <div data-prog="__2" id="" class="ft-page page-40 future-section future-page" data-id="__page-2">
195                 <h3 id="text-45" contenteditable="true">如果没有她在身后</h3>
196                 <img src="love2/iali14.jpg">
197             </div>
198             <div data-prog="__3" id="" class="ft-page page-41 future-section future-page" data-id="__page-3">
199                 <img src="love2/iali30_1.jpg" class="img1">
200                 <img src="love2/iali30_2.jpg" class="img2">
201                 <h3 id="text-46" contenteditable="true"> 他又怎会飞的更高更远</h3>
202             </div>
203             <div data-prog="__4" id="" class="ft-page page-42 future-section future-page" data-id="__page-4">
204                 <h3><span id="text-47" contenteditable="true">他不想这样。他要为她改变自己</span><br><span id="text-48" contenteditable="true">她说她喜欢狮子座的人,于是他许下愿望</span></h3>
205                 <img src="love2/iali69.jpg">
206             </div>
207             <div data-prog="__5" id="" class="ft-page page-43 future-section future-page" data-id="__page-5">
208                 <img src="love2/iali42.jpg">
209                 <h3 id="text-49" contenteditable="true">我愿为你变成狮子座</h3>
210             </div>
211             <div data-prog="__6" id="" class="ft-page page-44 left-img future-section future-page" data-id="__page-6">
212                 <h3><span id="text-50" contenteditable="true">爱情就像花草一样</span><br><span id="text-51" contenteditable="true">需要用包容来浇灌</span></h3>
213                 <img src="love2/iali0.jpg">
214             </div>
215             <div data-prog="__7" id="" class="ft-page page-45 left-img future-section future-page" data-id="__page-7">
216                 <h3><span id="text-52" contenteditable="true">再到后来,她要过生日了</span><br><span id="text-53" contenteditable="true">他开始为她准备礼物</span></h3>
217                 <img src="love2/iali18.jpg">
218             </div>
219         </div>
220         <div id="" data-prog="__8" class="ft-section section-8" data-id="__section-8">
221             <div data-prog="__1" id="" class="ft-page page-46 future-section" data-id="__page-1">
222                 <img src="love2/iali57.gif">
223                 <h3>
224                     <span id="text-54" contenteditable="true">看着礼物一件件准备好了</span>
225                     <span id="text-55" contenteditable="true">他好开心</span>
226                     <span id="text-56" contenteditable="true">因为他想象着她收到礼物时</span>
227                     <span id="text-57" contenteditable="true">开心的样子</span>
228                 </h3>
229             </div>
230             <div data-prog="__2" id="" class="ft-page page-47 top-text future-section future-page" data-id="__page-2">
231                 <img src="love2/iali58.jpg">
232                 <h3>
233                     <span id="text-58" contenteditable="true">想想后面还有一辈子</span>
234                     <span id="text-59" contenteditable="true">他好开心</span>
235                     <span id="text-60" contenteditable="true">因为可以和她</span>
236                     <span id="text-61" contenteditable="true">去全世界好多地方玩</span></h3>
237                 
238             </div>
239             <div data-prog="__3" id="" class="ft-page page-48 left-img future-section future-page" data-id="__page-3">
240                 <p><span id="text-62" contenteditable="true">他也会继续努力</span><br><span id="text-63" contenteditable="true">为了他和她的梦之城堡</span></p>
241                 <img src="love2/iali65.jpg">
242             </div>
243             <div data-prog="__4" id="" class="ft-page page-49 full-img future-section future-page" data-id="__page-4">
244             <img src="love2/iali71.jpg">
245                 <p class="text">
246                     <span class="text" id="text-64" contenteditable="true">他很幸福,因为他找到了她。他相信后面的每天都会是快乐的</span><br>
247                     <span class="text" id="text-65" contenteditable="true">简简单单,体会着与她在一起的每一个刻</span>
248                 </p>
249             </div>
250             <div data-prog="__5" id="" class="ft-page page-50 future-section future-page" data-id="__page-5">
251                 <p class="text" id="text-66" contenteditable="true">后来的一天,她说她不敢坐山车了,于是他就带她到别的地方玩。这只是他们幸福生活中的一件小事,小到无法引起别人的注意。可这是属于他和她的幸福生活。</p>
252                 <img src="love2/iali50_1.jpg" class="img1">
253                 <img src="love2/iali50_2.jpg" class="img2">
254             </div>
255             <div data-prog="__6" id="" class="ft-page page-51 future-section future-page" data-id="__page-6">
256                 <p>
257                     <span id="text-67" contenteditable="true">她:永远有多远?</span><br>
258                     <span id="text-68" contenteditable="true">他:比时间多一秒就是永远,我会永远爱你</span><br>
259                     <span id="text-69" contenteditable="true">她:世界有多大?</span><br>
260                     <span id="text-70" contenteditable="true">他:你走到哪里,世界就有多大</span>
261                     </p>
262             </div>
263         </div>
264         <div id="" data-prog="__9" class="ft-section section-9" data-id="__section-9">
265             <div data-prog="__1" id="" class="ft-page page-52 full-img future-section" data-id="__page-1">
266                 <h3 id="text-71" contenteditable="true">愿得一人心,白首不相离</h3>
267                 <img src="love2/iali20.jpg">
268             </div>
269             <div data-prog="__2" id="" class="ft-page page-53 future-section future-page" data-id="__page-2">
270                 <img src="love2/iali68.jpg" alt="happy birthday">
271                 <h6 id="text-72" contenteditable="true">亲爱的</h6>
272                 <h3 id="text-73" contenteditable="true">永远爱你</h3>
273             </div>
274             <div data-prog="__3" id="" class="ft-page page-54 center-img future-section future-page" data-id="__page-3">
275                 <div class="center-img">I love you</div>
276             </div>
277             <div data-prog="__4" id="" class="ft-page page-55 right-img future-section future-page" data-id="__page-4">
278                 <img src="love2/14915.jpg">
279                 <p class="text">
280                     <span id="text-74" contenteditable="true">他和她的故事会一直继续下去。</span><br>
281                     <span id="text-75" contenteditable="true">无论精彩、平淡都会是他们喜欢的。</span><br>
282                     <span id="text-76" contenteditable="true"></span><br>
283                     <span id="text-77" contenteditable="true">亲爱的,按"Esc"键将有惊喜♥♥</span><br>
284                     <br>
285                     <br>
286                     
287                 </p>                
288             </div>
289         </div>
290     </div>
291     <noscript><div class="nojavascript">您的浏览器禁用了javascript,无法正常浏览本页面</div></noscript>
292     
293     
294 
295 <audio autoplay="autopaly">
296                     <source src="http://qzone.haoduoge.com/up/1/MTgzMDk4MDA=.mp3" type="audio/mp3" />
297             </audio>
298     
299     <script src="love2/jquery.js"></script>
300     <script src="love2/all.js" tppabs="http://aijava.cn/demo/love/2014/js/all.min.js"></script>
301     <script src="love2/love.js" tppabs="http://aijava.cn/demo/love/2014/js/love.min.js"></script><div class="ft-default-progress"><div class="ft-section-thumb thumb-section-0" data-section="__0"><div data-page="__0" data-section="__0" class="ft-page-thumb thumb-page-0 actual"></div><div data-page="__1" data-section="__0" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__0" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__0" class="ft-page-thumb thumb-page-3"></div></div><div class="ft-section-thumb thumb-section-1" data-section="__1"><div data-page="__0" data-section="__1" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__1" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__1" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__1" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__1" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__1" class="ft-page-thumb thumb-page-5"></div></div><div class="ft-section-thumb thumb-section-2" data-section="__2"><div data-page="__0" data-section="__2" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__2" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__2" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__2" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__2" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__2" class="ft-page-thumb thumb-page-5"></div><div data-page="__6" data-section="__2" class="ft-page-thumb thumb-page-6"></div></div><div class="ft-section-thumb thumb-section-3" data-section="__3"><div data-page="__0" data-section="__3" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__3" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__3" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__3" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__3" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__3" class="ft-page-thumb thumb-page-5"></div><div data-page="__6" data-section="__3" class="ft-page-thumb thumb-page-6"></div></div><div class="ft-section-thumb thumb-section-4" data-section="__4"><div data-page="__0" data-section="__4" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__4" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__4" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__4" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__4" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__4" class="ft-page-thumb thumb-page-5"></div><div data-page="__6" data-section="__4" class="ft-page-thumb thumb-page-6"></div></div><div class="ft-section-thumb thumb-section-5" data-section="__5"><div data-page="__0" data-section="__5" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__5" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__5" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__5" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__5" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__5" class="ft-page-thumb thumb-page-5"></div><div data-page="__6" data-section="__5" class="ft-page-thumb thumb-page-6"></div></div><div class="ft-section-thumb thumb-section-6" data-section="__6"><div data-page="__0" data-section="__6" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__6" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__6" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__6" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__6" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__6" class="ft-page-thumb thumb-page-5"></div><div data-page="__6" data-section="__6" class="ft-page-thumb thumb-page-6"></div></div><div class="ft-section-thumb thumb-section-7" data-section="__7"><div data-page="__0" data-section="__7" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__7" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__7" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__7" class="ft-page-thumb thumb-page-3"></div><div data-page="__4" data-section="__7" class="ft-page-thumb thumb-page-4"></div><div data-page="__5" data-section="__7" class="ft-page-thumb thumb-page-5"></div></div><div class="ft-section-thumb thumb-section-8" data-section="__8"><div data-page="__0" data-section="__8" class="ft-page-thumb thumb-page-0"></div><div data-page="__1" data-section="__8" class="ft-page-thumb thumb-page-1"></div><div data-page="__2" data-section="__8" class="ft-page-thumb thumb-page-2"></div><div data-page="__3" data-section="__8" class="ft-page-thumb thumb-page-3"></div></div></div>
302     <div class="mPower"><span id="on" title="点击暂停"></span><span id="off" title="点击播放"></span></div>
303     <div style="display:none">
304         <script type="text/javascript">var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
305             document.write(unescape("%3Cscript src='" + _bdhmProtocol +     
306             "hm.baidu.com/h.js%3F016f5d60f3fb81c4ce4a180a4caec134' type='text/javascript'%3E%3C/script%3E"));
307         </script><script src="love2/h.js" type="text/javascript"></script>  
308         <script type="text/javascript">
309             var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
310             document.write(unescape("%3Cspan id='cnzz_stat_icon_5796950'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s13.cnzz.com/stat.php%3Fid%3D5796950%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));
311         </script><span id="cnzz_stat_icon_5796950"><a href="http://www.cnzz.com/stat/website.php?web_id=5796950" target="_blank" title="站长统计"><img src="love2/pic1.gif" border="0" hspace="0" vspace="0"></a></span><script src="love2/stat.php" type="text/javascript"></script><script src="love2/core.php" charset="utf-8" type="text/javascript"></script> 
312     </div>
313 
314 
315 </body></html>

 

部分效果:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

3、词云版表白

文件结构:

font为字体,image为背景图模板,可以自备,也可以私信或评论我发。
love.txt和stopwords.txt为词云文本。
word.py为主程序。
在这里插入图片描述

源码:

 1 #coding:utf-8
 2 from os import path
 3 from scipy.misc import imread
 4 import matplotlib.pyplot as plt
 5 import jieba
 6 
 7 from wordcloud import WordCloud, STOPWORDS, ImageColorGenerator
 8 
 9 stopwords = {}
10 def importStopword(filename=''):
11     global stopwords
12     f = open(filename, 'r', encoding='utf-8')
13     line = f.readline().rstrip()
14 
15     while line:
16         stopwords.setdefault(line, 0)
17         stopwords[line] = 1
18         line = f.readline().rstrip()
19 
20     f.close()
21 
22 def processChinese(text):
23     seg_generator = jieba.cut(text)  # 使用结巴分词,也可以不使用
24 
25     seg_list = [i for i in seg_generator if i not in stopwords]
26 
27     seg_list = [i for i in seg_list if i != u' ']
28 
29     seg_list = r' '.join(seg_list)
30 
31     return seg_list
32 
33 importStopword(filename='./stopwords.txt')
34 
35 # 获取当前文件路径
36 # __file__ 为当前文件, 在ide中运行此行会报错,可改为
37 # d = path.dirname('.')
38 d = path.dirname(__file__)
39 
40 text = open(path.join(d, 'love.txt'),encoding ='utf-8').read()
41 
42 #如果是中文
43 text = processChinese(text)#中文不好分词,使用Jieba分词进行
44 
45 # read the mask / color image
46 # taken from http://jirkavinse.deviantart.com/art/quot-Real-Life-quot-Alice-282261010
47 # 设置背景图片
48 back_coloring = imread(path.join(d, "./image/love.jpg"))
49 
50 wc = WordCloud( font_path='./font/叶立群几何体.ttf',#设置字体
51                 background_color="black", #背景颜色
52                 max_words=2000,# 词云显示的最大词数
53                 mask=back_coloring,#设置背景图片
54                 #max_font_size=100, #字体最大值
55                 random_state=42,
56                 )
57 # 生成词云, 可以用generate输入全部文本(中文不好分词),也可以我们计算好词频后使用generate_from_frequencies函数
58 wc.generate(text)
59 # wc.generate_from_frequencies(txt_freq)
60 # txt_freq例子为[('词a', 100),('词b', 90),('词c', 80)]
61 # 从背景图片生成颜色值
62 image_colors = ImageColorGenerator(back_coloring)
63 
64 plt.figure()
65 # 以下代码显示图片
66 plt.imshow(wc)
67 plt.axis("off")
68 plt.show()
69 # 绘制词云
70 '''plt.figure()
71 
72 # recolor wordcloud and show
73 # we could also give color_func=image_colors directly in the constructor
74 plt.imshow(wc.recolor(color_func=image_colors))
75 plt.axis("off")
76 
77 # 绘制背景图片为颜色的图片
78 plt.figure()
79 plt.imshow(alice_coloring, cmap=plt.cm.gray)
80 plt.axis("off")
81 plt.show()
82 '''
83 # 保存图片
84 wc.to_file(path.join(d, "名称.png"))

 

运行效果图:
在这里插入图片描述

在这里插入图片描述

若出现报错:cannot import name ‘imread’ from ‘scipy.misc’

解决办法见:ImportError: cannot import name ‘imread’ from ‘scipy.misc’ 解决办法

因为每次在本文更新后,CSDN都会审核一段时间才能发出来,所以新开一文更新。

情人节表白合集

在这里插入图片描述

在这里插入图片描述

 

posted @ 2021-02-14 12:23  BugMiaowu2021  阅读(345)  评论(0编辑  收藏  举报