创新互联Python教程:python可以编写win程序吗?

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教程:python可以编写win程序吗?
地址分享:http://hxwzsj.com/article/cdjeicj.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 成都网站建设公司 网站设计 LED网站设计方案 网站建设方案 企业网站建设公司 成都网站建设公司 宜宾网站设计 营销型网站建设 成都做网站建设公司 成都商城网站制作 成都网站建设 盐亭网站设计 专业网站建设 网站设计制作 达州网站设计 成都网站建设 成都网站制作 成都网站建设推广 响应式网站设计 四川成都网站设计 成都h5网站建设 成都网站设计