python读取文件的版本信息

版本号一共四位:高2位和低2位,get_version_number返回的是一个list,在main中用点将其连接起来了。

#coding:gbk #www.hbxcyz.cn from win32api import GetFileVersionInfo, LOWORD, HIWORD def get_version_number (filename): try: info = GetFileVersionInfo (filename, "//") ms = info['FileVersionMS'] ls = info['FileVersionLS'] return HIWORD (ms), LOWORD (ms), HIWORD (ls), LOWORD (ls) except: return 0,0,0,0 if __name__ == '__main__': filename = "D://My Programme//search//dist//Search.exe" print get_version_number (filename) print ".".join ([str (i) for i in get_version_number (filename)])

你可能感兴趣的:(python读取文件的版本信息)