import platform
if platform.release() == 'post2008Server' and platform.version() == '6.2.9200':
print "It's windows 8"我以前用过这个来识别Windows 8。但是Windows 10的返回方式是一样的。那么还有其他方法来识别它吗?
发布于 2016-03-29 07:10:11
有了下面的Python版本,一切都很好。
Python 3.5.1:
>>> import platform
>>> platform.release()
'10'
>>> platform.version()
'10.0.10240'Python 2.7.11
>>> import platform
>>> platform.release()
'10'
>>> platform.version()
'10.0.10240'升级到至少2.7.x怎么样?
编辑:正如@Rogalski所提到的,您可以始终使用管道传递ver命令,这应该独立于Python返回以下内容:
>>> import subprocess
>>> subprocess.Popen('ver', shell=True, stdout=subprocess.PIPE).communicate()[0]
'\r\nMicrosoft Windows [Version 10.0.10240]\r\n'https://stackoverflow.com/questions/36276994
复制相似问题