12
How can I do in Python to identify which operating system is being used?
12
How can I do in Python to identify which operating system is being used?
10
import os
print(os.name)
That’s usually what matters, indicating what you can and can’t 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 for a specific version then you can use it:
import platform
print(platform.system())
print(platform.release())
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
9
import os
print os.name
#Saída: posix
import platform
platform.system()
#Saída: 'Linux'
platform.release()
#Saída: '2.6.22-15-generic'
Taken from that question
4
Simple (like almost everything in Python :p) - The outputs are from the test I did in my OS
>>> import os
>>> print os.name
nt
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'10'
4
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())
Browser other questions tagged python operating-system
You are not signed in. Login or sign up in order to post.