创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!

这篇文章将为大家详细讲解有关使用python编写exe程序的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
python可以编写win程序。win程序的格式是exe,下面我们就来看一下使用python编写exe程序的方法。
编写好python程序后py2exe模块即可将其打包为exe程序。
实际操作过程:
1、在app.py同一目录下建立文件,setup.py 内容根据需要增删改,
#setup.py
import sys, os
from cx_Freeze import setup, Executable
__version__ = "1.1.0"
#include_files = ['logging.ini', 'config.ini', 'running.png']
include_files = []
excludes = ["tkinter"]
#packages = ["os", "idna", "requests","json","base64","pyodbc"]
packages = ["os", "idna", "requests","json","base64"]
setup(
name = "appname",
description='App Description',
version=__version__,
options = {"build_exe": {
'packages': packages,
'include_files': include_files,
'excludes': excludes,
'include_msvcr': True,
}},
executables = [Executable("boxLayout.py",base="Win32GUI")]
)2、执行命令
python setup.py bdist_msi
之后生成两个文件夹,build 和dist
在build\exe.win32-3.6找到生成的exe文件

关于使用python编写exe程序的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。