如何使用Python获取系统信息? [英] How to get the system info with Python?

查看:108
本文介绍了如何使用Python获取系统信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取在什么环境下运行软件的信息. python是否有一个用于此目的的库?

I need to get the info under what environment the software is running. Does python have a library for this purpose?

我想知道以下信息.

  • 操作系统名称/版本
  • CPU名称,时钟速度
  • CPU核心数量
  • 内存大小

推荐答案

其中一些可以从

some of these could be obtained from the platform module:

>>> import platform
>>> platform.machine()
'x86'
>>> platform.version()
'5.1.2600'
>>> platform.platform()
'Windows-XP-5.1.2600-SP2'
>>> platform.uname()
('Windows', 'name', 'XP', '5.1.2600', 'x86', 'x86 Family 6 Model 15 Stepping 6, GenuineIntel')
>>> platform.system()
'Windows'
>>> platform.processor()
'x86 Family 6 Model 15 Stepping 6, GenuineIntel'

这篇关于如何使用Python获取系统信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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