5个无聊Python程序,用Python整蛊你的朋友们吧
生活随笔
收集整理的這篇文章主要介紹了
5个无聊Python程序,用Python整蛊你的朋友们吧
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
來源:https://dream.blog.csdn.net/
Python 能做很多無聊,但有意思的事情,例如接下來的一些案例。
以下程序,不要發代碼,要不實現不了你整蠱的目的。
要打包成一個?exe?程序,發給朋友才有意思。
使用?pip install pyinstaller。
打包命令如下:
pyinstaller?-F?文件名.py過程中如果出現 BUG(一般是編碼錯誤),文末有解決方案
無聊程序之一
while True:n = input("猜猜我在想啥?")print("猜錯嘍")你的朋友將永遠無法知道你在想什么。
當然我安裝 360 之后,程序沒了。有興趣研究免殺的,可以在給本文點個贊,點贊過 100,我出套 Python 免殺教程。
無聊程序之二
死命彈窗
import tkinter.messageboxwhile True:tkinter.messagebox.showerror('Windows 錯誤','你的電腦正在被攻擊!')運行之后,很就刺激了,如果對方不會殺進程,更刺激。
無聊程序之三
調用默認瀏覽器,無限打開 CSDN ,讓他愛上學習。
import webbrowser while True:webbrowser.open('www.csdn.net')額,使用之后,我自己的電腦死機了。
瞬間 CPU…
無聊程序之四
這個程序就動感多了,會隨機出現彈窗。
import tkinter as tk import random import threading import timedef 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()運行效果如下圖所示,非常帶勁,可以任意修改。
無聊程序之五
該程序在我看來能排到第一,甚至可以和當下最火的槍茅臺案例結合一下。
import os import time a = """oooo oooooooooo. .oooooo..o oooo o8o oooo oooo`888 `888' `Y8b d8P' `Y8 `888 `"' `888 `888888 888 888 Y88bo. .ooooo. .ooooo. 888 oooo oooo 888 888888 888 888 `"Y8888o. d88' `88b d88' `"Y8 888 .8P' `888 888 888888 888 888 8888888 `"Y88b 888ooo888 888 888888. 888 888 888888 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)別運行,運行之后別怪我。
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_cmdtxt = 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_pythonreturn exec_command(*cmdargs, **kwargs)File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py", line 321, in exec_commandout = out.decode(encoding) AttributeError:?'str'?object?has?no?attribute?'decode'截圖如下:
按照 BUG 提示的位置,修改下述代碼:
打包成功在 dist 文件中找尋 exe 程序即可。
總結
以上是生活随笔為你收集整理的5个无聊Python程序,用Python整蛊你的朋友们吧的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国版“微软”要来了?某国产操作系统称已
- 下一篇: 5.2k Star!一款 Python