Python整蛊小程序代码怎么写
导读:本文共2622字符,通常情况下阅读需要9分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 要打包成一个 exe 程序,发给朋友才有意思。使用 pip install pyinstaller。打包命令如下:pyinstaller-F文件名.py过程中如果出现 BUG(一般是编码错误),点击导航查看解决方案无聊程序之一whileTrue:n=input("猜猜我在想啥?")print("猜错喽")你的朋友将永远... ...
目录
(为您整理了一些要点),点击可以直达。要打包成一个 exe 程序,发给朋友才有意思。
使用 pip install pyinstaller。
打包命令如下:
pyinstaller-F文件名.py
过程中如果出现 BUG(一般是编码错误),点击导航查看解决方案
无聊程序之一
whileTrue:n=input("猜猜我在想啥?")print("猜错喽")
你的朋友将永远无法知道你在想什么。
当然我安装 360 之后,程序没了。有兴趣研究免杀的,可以在给本文点个赞,点赞过 100,橡皮擦出套 Python 免杀教程。
无聊程序之二
死命弹窗
importtkinter.messageboxwhileTrue:tkinter.messagebox.showerror('Windows错误','你的电脑正在被攻击!')
运行之后,很就刺激了,如果对方不会杀进程,更刺激。
无聊程序之三
调用默认浏览器,无限打开 CSDN ,让他爱上学习。
importwebbrowserwhileTrue:webbrowser.open('www.csdn.net')
额,使用之后,橡皮擦自己的电脑死机了。
瞬间 CPU…
无聊程序之四
这个程序就动感多了,会随机出现弹窗。
importtkinterastkimportrandomimportthreadingimporttimedefboom():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=[]foriinrange(100):t=threading.Thread(target=boom)threads.append(t)time.sleep(0.1)threads[i].start()
运行效果如下图所示,非常带劲,可以任意修改。
无聊程序之五
该程序在橡皮擦看来能排到第一,甚至可以和当下最火的枪茅台案例结合一下。
importosimporttimea="""oooooooooooooo..oooooo..oooooo8ooooooooo`888`888'`Y8bd8P'`Y8`888`"'`888`888888888888Y88bo..ooooo..ooooo.888oooooooo888888888888888`"Y8888o.d88'`88bd88'`"Y8888.8P'`8888888888888888888888888`"Y88b888ooo888888888888.888888888888888d88'oo.d8P888.o888.o8888`88b.888888888.o.88Po888bood8P'8""88888P'`Y8bod8P'`Y8bod8P'o888oo888oo888oo888oo888o`Y888P功能列表:1.预约商品2.秒杀抢购商品"""print(a)key=input("请选择:")ifkey=="1":time.sleep(1.5)print('没有预约到\n')time.sleep(3)print('没事的,来抱一哈\n')else:print("既然如此...")time.sleep(3)print("那你想得美~~~~~")os.system('shutdown-r-t10')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_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'
截图如下:
按照 BUG 提示的位置,修改下述代码:
out=out.decode(encoding)#改为out=out
打包成功在 dist 文件中找寻 exe 程序即可。
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
Python整蛊小程序代码怎么写的详细内容,希望对您有所帮助,信息来源于网络。