如何为程序添加版本号

本文介绍了如何使用Python的PyInstaller库来修改exe程序的版本信息。首先需要安装Python和PyInstaller,然后创建一个包含版本信息的file_version_info.txt文件,接着将文件中的版本号替换为你需要的版本,最后通过命令行运行pyi-set_version命令更新程序的版本号。
部署运行你感兴趣的模型镜像

首先准备好需要添加版本号的exe程序

然后安装python,并下载pyinstaller

pip install  PyInstaller

将下面内容保存到文档file_version_info.txt

# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
  ffi=FixedFileInfo(
    # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
    # Set not needed items to zero 0.
    filevers=(1, 1, 110, 254),
    prodvers=(1, 1, 110, 254),
    # Contains a bitmask that specifies the valid bits 'flags'r
    mask=0x0,
    # Contains a bitmask that specifies the Boolean attributes of the file.
    flags=0x0,
    # The operating system for which this file was designed.
    # 0x4 - NT and there is no need to change it.
    OS=0x4,
    # The general type of file.
    # 0x1 - the file is an application.
    fileType=0x1,
    # The function of the file.
    # 0x0 - the function is not defined for this fileType
    subtype=0x0,
    # Creation date and time stamp.
    date=(0, 0)
    ),
  kids=[
    StringFileInfo(
      [
      StringTable(
        '080403a8',
        [StringStruct('Comments', '客户端'),
        StringStruct('CompanyName', ''),
        StringStruct('FileDescription', ''),
        StringStruct('FileVersion', '1.1.110.254'),
        StringStruct('LegalCopyright', 'SIENT Corp.All rights reserved'),
        StringStruct('LegalTrademarks', 'SIENT Corp.All rights reserved'),
        StringStruct('ProductName', '你的程序名称')])
      ]), 
    VarFileInfo([VarStruct('Translation', [2052, 936])])
  ]
)

我的程序版本是1.1.110.254,你需要把代码中的3处版本号都改成你需要的

然后在命令行中运行

pyi-set_version file_version_info.txt文档路径 你的程序路径

完成

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值