如何在Python中找到当前的操作系统? [英] How can I find the current OS in Python?

查看:86
本文介绍了如何在Python中找到当前的操作系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

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中找到当前的操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆