2022年 11月 16日

5 个无聊 Python 程序,用 Python 整蛊你的朋友们吧(纯属娱乐慎用)

程序环境:
python3.7

pyinstaller库–用于将程序打包成exe可执行文件。

安转:pip install pyinstaller

pyinstaller打包命令:pyinstaller -F -w 文件名.py

这个程序可以跟朋友玩玩

无聊程序之一

1
2
3
while
 
True
:
    

=
 
input
(
"猜猜我在想啥?"
)
    
print
(
"猜错喽"
)

 

无聊程序之二

死命弹窗

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

 

 …

无聊程序之三

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

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

 

 瞬间 CPU…

 

无聊程序之四

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

  1. import tkinter as tkimport randomimport threadingimport time
  2. def boom():
  3. window = tk.Tk()
  4. width = window.winfo_screenwidth()
  5. height = window.winfo_screenheight()
  6. a = random.randrange(0, width)
  7. b = random.randrange(0, height)
  8. window.title('你是一个傻狍子')
  9. window.geometry("200x50" + "+" + str(a) + "+" + str(b))
  10. tk.Label(window, text='你是一个傻狍子', bg='green',
  11. font=('宋体', 17), width=20, height=4).pack()
  12. window.mainloop()
  13. threads = []for i in range(100):
  14. t = threading.Thread(target=boom)
  15. threads.append(t)
  16. time.sleep(0.1)
  17. threads[i].start()

运行效果如下图所示,非常带劲,可以任意修改。朋友揍你别找我.;..

 

 

无聊程序之五

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

  1. import os
  2. import time
  3. a = """
  4. oooo oooooooooo. .oooooo..o oooo o8o oooo oooo
  5. `888 `888' `Y8b d8P' `Y8 `888 `"' `888 `888
  6. 888 888 888 Y88bo. .ooooo. .ooooo. 888 oooo oooo 888 888
  7. 888 888 888 `"Y8888o. d88' `88b d88' `"Y8 888 .8P' `888 888 888
  8. 888 888 888 8888888 `"Y88b 888ooo888 888 888888. 888 888 888
  9. 888 888 d88' oo .d8P 888 .o 888 .o8 888 `88b. 888 888 888
  10. .o. 88P o888bood8P' 8""88888P' `Y8bod8P' `Y8bod8P' o888o o888o o888o o888o o888o
  11. `Y888P
  12. 功能列表:
  13. 1.预约商品
  14. 2.秒杀抢购商品
  15. """
  16. print(a)
  17. key = input("请选择:")
  18. if key == "1":
  19. time.sleep(1.5)
  20. print('没有预约到n')
  21. time.sleep(3)
  22. print('没事的,来抱一哈n')
  23. else:
  24. print("既然如此...")
  25. time.sleep(3)
  26. print("那你想得美~~~~~")
  27. os.system('shutdown -r -t 10')
  28. time.sleep(10)

别运行,运行之后别怪我。看看就行,我也不敢运行。