单文件模式 --onefile

70.4 单文件模式 --onefile

--onefile 打成单个 exe,方便分发;启动时会解压到临时目录,略慢于文件夹模式。

--onedir(默认)生成一个文件夹,启动更快,适合较大程序。

💡 作业/小工具推荐 --onefile,一个文件好交。

单文件打包

pyinstaller --onefile hello.py

# 输出:dist\hello.exe(只有一个文件)