Py代码转成exe
1.安装,在cmd里输入一行命令即可
pip install pyinstaller
2.在cmd里输入打包成exe的命令
pyinstaller -F xxxx.py(要打包的py文件)
关于pyinstaller功能最最最全面的解释
pyintsaller --help
获取py打包为exe的 文件夹 路径
import sys
import os
def get_exe_directory():
"""
获取当前可执行文件所在的文件夹的完整路径。
"""
exe_path = sys.executable
exe_directory = os.path.dirname(exe_path)
return exe_directory
if __name__ == "__main__":
exe_directory = get_exe_directory()
print("Executable directory:", exe_directory)
os.system("pause")







网友评论