为什么 platform.release() return “8” 在 Windows 10 中?

Why does platform.release() return "8" in Windows 10?

我 运行 在我的 Windows 10 工作站上:

import platform
print platform.release()
> 8

我有点困惑。当我在 Windows 10 时,响应不应该是“10”吗?

我做了一些挖掘...

An issue was resolved for Python 2.7.10 according to its release notes:

  • Issue #16176: Properly identify Windows 8 via platform.platform()

然而,使用 Windows 10 您仍然没有得到正确的响应。为此,2015 年 9 月下旬创建了一个修复程序:https://hg.python.org/cpython/rev/2f57270374f7

由于这是在 2.7.10 版本(2015 年 5 月下旬发布)之后执行的,因此有望在未来的版本中实现。现在它应该进入 2.7.11,计划于 2015 年 12 月发布。

此修复使 platform 从 kernel32.dll 读取 Windows 版本以避免兼容性问题。

如果系统是基于 Windows,现在的解决方法是执行 ver 命令,然后手动解析响应。

编辑:确实,这已在 Python 2.7.11 中修复:

import platform
print platform.release()
> 10