可能重复: Python:我正在运行什么操作系统?
正如标题所述,如何在python中找到当前的操作系统?
As the title says, how can I find the current operating system in python?
推荐答案我通常使用 sys.platform (文档)以获取平台。 sys.platform 将区分linux,其他unix和OS X,而 os.name 是 posix 。
I usually use sys.platform (docs) to get the platform. sys.platform will distinguish between linux, other unixes, and OS X, while os.name is "posix" for all of them.
有关更多详细信息,请使用平台模块。它具有跨平台功能,可为您提供有关计算机体系结构,操作系统和操作系统版本,Python版本等的信息。它还具有特定于操作系统的功能,可获取诸如特定的Linux发行版之类的信息。
For much more detailed information, use the platform module. This has cross-platform functions that will give you information on the machine architecture, OS and OS version, version of Python, etc. Also it has os-specific functions to get things like the particular linux distribution.
更多推荐
如何在Python中找到当前的操作系统?
发布评论