python可以编写win程序吗?
python可以编写win程序。win程序的格式是exe,下面我们就来看一下使用python编写exe程序的方法。
编写好python程序后py2exe模块即可将其打包为exe程序。
实际操作过程:
1、在app.py同一目录下建立文件,setup.py内容根据需要增删改,
#setup.py
importsys,os
fromcx_Freezeimportsetup,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='AppDescription',
version=__version__,
options={"build_exe":{
'packages':packages,
'include_files':include_files,
'excludes':excludes,
'include_msvcr':True,
}},
executables=[Executable("boxLayout.py",base="Win32GUI")]
)
2、执行命令
pythonsetup.pybdist_msi
之后生成两个文件夹,build和dist
在build\exe.win32-3.6找到生成的exe文件
以上内容为大家介绍了python可以编写win程序吗?希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
python如何进行类型转换的
python提供了将变量或值从一种类型转换成另一种类型的内置函数。1、int:将符合数学格式数字型字符串转换成整数。>>>int('123')1232、s...详情>>
2023-11-07 18:51:20
python怎么生成随机数
以下实例演示了python如何生成一个随机数:#生成0~9之间的随机数#导入random(随机数)模块importrandomprint(random.randint(0,9))执行以上代码...详情>>
2023-11-07 17:09:17
python如何删除空格
python中的字符串方法提供了如下常用的方法来删除空白:strip():删除字符串前后的空白。lstrip():删除字符串前面(左边)的空白。rstrip():删...详情>>
2023-11-07 14:57:44
python怎么调用实例方法
在Python的类体中定义的方法默认都是实例方法,也示范了通过对象来调用实例方法。但要提醒大家的是,Python的类在很大程度上可看做是一个独立的...详情>>
2023-11-07 14:17:57