确定操作系统的名称

os 模块提供了一个接口,用于确定代码当前运行的操作系统类型。

os.name

这可以在 Python 3 中返回以下内容之一:

  • posix
  • nt
  • ce
  • java

可以从 sys.platform 中检索更详细的信息