python os.name
os.name
os.name是python标准库os内的一个变量,可以用来查看当前所使用的计算机的操作系统的名称。不同的系统,会返回不同的值,如下表。
os.name返回值表
系统 | os.name返回值 |
---|---|
windows | 'nt' |
Linux | 'posix' |
mac os x | 'posix' |
os.name实例代码
>>> import os
>>> os.name #鄙人的操作系统为mac osx
'posix'
>>> from os import name
>>> name
'posix'
>>> from os import *
>>> name
'posix'