import platform
if platform.release() == 'post2008Server' and platform.version() == '6.2.9200':
print "It's windows 8"
I have used this before to recognize Windows 8. But it's returning same for Windows 10. So is there any other way to recognize it ?
With the following Python versions everything works fine.
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'
How about upgrading to at least 2.7.x ?
Edit: As mentioned by @Rogalski, you can always pipe the ver
command, and this should return the following independently of the Python version:
>>> import subprocess
>>> subprocess.Popen('ver', shell=True, stdout=subprocess.PIPE).communicate()[0]
'\r\nMicrosoft Windows [Version 10.0.10240]\r\n'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With