为什么platform.release()返回"8"?在Windows 10中? [英] Why does platform.release() return "8" in Windows 10?
问题描述
我在Windows 10工作站上运行它:
I run this on my Windows 10 workstation:
import platform
print platform.release()
> 8
我有些困惑.响应应该不是Windows 10上的"10"吗?
I'm somewhat perplexed. Should the response not have been "10" as I'm on Windows 10?
推荐答案
我做了一些挖掘工作...
I did some digging...
一个问题已根据Python 2.7.10的
An issue was resolved for Python 2.7.10 according to its release notes:
- 问题#16176:通过platform.platform()正确识别Windows 8
- Issue #16176: Properly identify Windows 8 via platform.platform()
但是,对于Windows 10,您仍然无法获得正确的响应.为此,我们在2015年9月下旬创建了一个修复程序: https://hg.python.org/cpython/rev/2f57270374f7
However, with Windows 10 you still don't get the proper response. For this, a fix was created in late September, 2015: https://hg.python.org/cpython/rev/2f57270374f7
由于此操作是在2.7.10版本(2015年5月下旬发布)之后执行的,因此有望将其纳入将来的版本中.现在,它应该进入计划于2015年12月发行的2.7.11.
As this was performed after the 2.7.10 release (released in late May, 2015), this will hopefully make it into a future release. Right now it should make it into 2.7.11 which is scheduled for a December 2015 release.
此修复程序使platform
从kernel32.dll读取Windows版本,以避免兼容性问题.
The fix makes platform
read the Windows version from kernel32.dll to avoid compatibility issues.
现在的解决方法是,如果系统基于Windows,则执行ver
命令,然后手动解析响应.
A workaround right now could be to execute the ver
command if the system is Windows based, and then parse the response manually.
编辑:的确,这已在Python 2.7.11中修复:
EDIT:Indeed, this was fixed in Python 2.7.11:
import platform
print platform.release()
> 10
这篇关于为什么platform.release()返回"8"?在Windows 10中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!