I want to find out what OS a person has in Python. I know I could always do this:
try:
os.system(unixonlycommand)
except:
os.system(windowsonlycommand)
But is there another way to do it? A special module for that or something?
I want to find out what OS a person has in Python. I know I could always do this:
try:
os.system(unixonlycommand)
except:
os.system(windowsonlycommand)
But is there another way to do it? A special module for that or something?
返回系统/操作系统名称,例如
'Linux'
、'Windows'
或'Java'
。如果无法确定值,则返回空字符串。
您还应该查看platform
模块中的其他方法,具体取决于您要执行的操作。
也相关:sys.platform
.