How can I do in Python to identify which operating system is being used?
How can I do in Python to identify which operating system is being used?
import os
print(os.name)
This is usually what matters, what you can and can not use in your application.
If you really want to show someone what the operating system is or if you want to do something very specific to a specific version there you can use:
import platform
print(platform.system())
print(platform.release())
See running on ideone .
import os
print os.name
#Saída: posix
import platform
platform.system()
#Saída: 'Linux'
platform.release()
#Saída: '2.6.22-15-generic'
Retired from this question
Simple (like almost everything in Python: p) - The outputs are from the test I did in my SO
>>> import os
>>> print os.name
nt
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'10'
import platform
#PEGAR A VERSÃO COMPLETA
print(platform.platform())
#PEGAR O SISTEMA OPERACIONAL
print(platform.system())
#PEGAR A VERSÃO DO SISTEMA OPERACIONAL
print(platform.release())
#PEGAR A VERSÃO COMPLETA DO SISTEMA OPERACIONAL
print(platform.version())