0
我想找出一个人在Python中的操作系统。我知道,我总是可以做到这一点:如何找出用户正在运行的操作系统?
try:
os.system(unixonlycommand)
except:
os.system(windowsonlycommand)
但有另一种方式做到这一点?一个特殊的模块,或什么?
我想找出一个人在Python中的操作系统。我知道,我总是可以做到这一点:如何找出用户正在运行的操作系统?
try:
os.system(unixonlycommand)
except:
os.system(windowsonlycommand)
但有另一种方式做到这一点?一个特殊的模块,或什么?
返回系统/ OS的名称,例如
'Linux'
,'Windows'
或'Java'
。如果无法确定值,则返回空字符串。
您还应该看看platform
模块中的其他方法,具体取决于您正在尝试执行的操作。
也相关:sys.platform
。
查看此帖子可能会有帮助。 http://stackoverflow.com/questions/1421357/how-do-i-get-the-operating-system-name-in-a-friendly-manner-using-python-2-5 – 2012-04-06 13:52:52