整蛊朋友的 Python 程序
以下程序,不要发代码,要不实现不了你整蛊的目的。要打包成一个 exe
程序,发给朋友才有意思。
无聊程序之一
while True:
n = input("猜猜我在想啥?")
print("猜错喽")
你的朋友将永远无法知道你在想什么。
当然安装 360 之后,程序没了。
无聊程序之二
死命弹窗
import tkinter.messagebox
while True:
tkinter.messagebox.showerror('Windows 错误','你的电脑正在被攻击!')
运行之后,很就刺激了,如果对方不会杀进程,更刺激。
无聊程序之三
调用默认浏览器,无限打开 CSDN ,让他爱上学习。
import webbrowser
while True:
webbrowser.open('www.csdn.net')
额,使用之后,可能会导致电脑死机了。
无聊程序之四
这个程序就动感多了,会随机出现弹窗。
import tkinter as tk
import random
import threading
import time
def boom():
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='green',
font=('宋体', 17), width=20, height=4).pack()
window.mainloop()
threads = []
for i in range(100):
t = threading.Thread(target=boom)
threads.append(t)
time.sleep(0.1)
threads[i].start()
运行效果如下图所示,非常带劲,可以任意修改。
打包命令以及可能出现的问题
pyinstaller -F 文件名.py
pyinstaller 编码可能出现的问题
在使用 pyinstaller 进行打包 exe 的时候,会出现如下错误:
按照 BUG 提示的位置,修改下述代码:
out = out.decode(encoding) # 改为 out = out
打包成功在 dist 文件中找寻 exe 程序即可。