更新时间:2023-11-13 21:01:46
我通常使用 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.