美文网首页python编程
Python代码转成exe

Python代码转成exe

作者: zip11 | 来源:发表于2024-03-19 13:21 被阅读0次

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")

相关文章

网友评论

    本文标题:Python代码转成exe

    本文链接:https://www.haomeiwen.com/subject/opmcgdtx.html