首页 > 技术文章 > Python 获得程序 exe 的版本号

ibingshan 2019-05-17 16:12 原文

Python 获得程序 exe 的版本号

python中需要安装 pywin32 包

# based on http://stackoverflow.com/questions/580924/python-windows-file-version-attribute
from win32com.client import Dispatch
 
def get_version_via_com(filename):
    parser = Dispatch("Scripting.FileSystemObject")
    version = parser.GetFileVersion(filename)
    return version
 
if __name__ == "__main__":
    path = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
    print get_version_via_com(path)

 

推荐阅读