def getFileVersion(file_name):
info = win32api.GetFileVersionInfo(file_name, os.sep)
ms = info['FileVersionMS']
ls = info['FileVersionLS']
version = '%d.%d.%d.%04d' % (win32api.HIWORD(ms), win32api.LOWORD(ms), win32api.HIWORD(ls), win32api.LOWORD(ls))
return version
#已知文件名的情况下,可以用这个函数def getFileInfo(filepath):
info = {}
if os.path.isfile(filepath):
info['TimeCreated'] = os.path.getctime(filepath)
info['TimeModified'] = os.path.getatime(filepath)
info['Size'] = os.path.getsize(filepath)
return info
查下manual就可以知道了,有多个类似变量可用sys.version
A string containing the version number of the Python interpreter plus additional information on the build number and compiler used. This string is displayed when the interactive interpreter is started. Do not extract version information out of it, rather, use version_info and the functions provided by the platform module.
如果是给人读,用 sys.version,
如果是给机器比较,用 sys.version_info,
如果是判断是不是 PyPy 等第三方实现,用 sys.implementation(要 Python 3.3)。
例子:
import sys
if sys.version_info <(3, 4):
raise RuntimeError('At least Python 3.4 is required')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)