前言
sys.getwindowsversion() 返回一个元组,描述当前Windows运行的版本信息,元素的名称为:major,minor,build,platform,service_pack_mirror,service_pack_major,suite_mask,product_type. 其中service_pack是字符串,其它的均为数字这些组件可以使用名称进行访问,如sys.getwindowsversion()[0],相当于sys.getwindowsversion().major。为了兼容老版本,仅前5个元素可以被索引引用:
可被索引引用的元素
Constant | Platform |
---|
0 (VER_PLATFORM_WIN32s) | Win32s on Windows 3.1 |
1 (VER_PLATFORM_WIN32_WINDOWS) | Windows 95/98/ME |
2 (VER_PLATFORM_WIN32_NT) | Windows NT/2000/XP/x64 |
3 (VER_PLATFORM_WIN32_CE) | Windows CE |
product_type可能的值
Constant | Meaning |
---|
1 (VER_NT_WORKSTATION) | The system is a workstation. |
2 (VER_NT_DOMAIN_CONTROLLER) | The system is a domain controller. |
3 (VER_NT_SERVER) | The system is a server, but not a domain controller. |
sys.getwindowsversion() 运行的值
import sys
print(sys.getwindowsversion())
"""
sys.getwindowsversion(major=10, minor=0, build=18363, platform=2, service_pack='')
"""