使用Python获取Windows系统信息

作者:佚名 上传时间:2023-03-18 运行软件:Visual Studio Code 软件版本:Python 3.8.2 版权申诉

该示例代码使用Python编写,通过调用Windows系统API获取系统信息,如CPU信息、内存信息、磁盘信息等。

import os
import platform

def get_cpu_info():
    return platform.processor()

def get_memory_info():
    memory_info = os.popen('wmic memorychip get capacity').read().split('\n')[1:-1]
    total_memory = 0
    for memory in memory_info:
        total_memory += int(memory)
    return total_memory/1024/1024    #MB

def get_disk_info():
    disk_info = os.popen('wmic diskdrive get size').read().split('\n')[1:-1]
    total_disk = 0
    for disk in disk_info:
        total_disk += int(disk)
    return total_disk/1024/1024/1024  #GB

print("CPU信息:", get_cpu_info())
print("内存信息:", get_memory_info(), "MB")
print("磁盘信息:", get_disk_info(), "GB")

免责申明:文章和图片全部来源于公开网络,如有侵权,请通知删除 server@dude6.com

用户评论
相关推荐
使用Python获取Windows系统信息
该示例代码使用Python编写,通过调用Windows系统API获取系统信息,如CPU信息、内存信息、磁盘信息等。import osimport platformdef get_cpu_inf
Python 3.8.2
Visual Studio Code
2023-03-18 19:56
Python使用WMI获取和修改Windows系统信息
在Python中,可以使用WMI来从Windows操作系统中获取和修改各种系统信息。如何安装WMI Python模块以及如何使用WMI查询不同的系统对象,如CIM_DataFile、CIM_Proce
docx
15.25KB
2023-06-09 04:02
使用PythonWindows系统获取系统信息
该示例代码是一个Python脚本,用于在Windows系统中获取各种系统信息,例如CPU、内存、硬盘等信息。实现方式是使用Python内置的winreg、psutil、wmi等模块。import p
Python 3.9.1
Python
2023-05-29 16:37
使用Python获取Windows系统信息的方法
本文介绍了使用Python编程语言获取Windows系统信息的方法。通过调用Windows操作系统提供的API或者使用第三方库,我们可以获取到系统的相关信息,包括硬件信息、网络信息、进程信息等。本文主
Python 3.9.2
Python 编程语言
2023-10-15 19:24
Python WMI获取Windows系统信息 监控系统
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 #http://www.cnblogs.com/liu-ke/ 4 imp
python使用wmi模块获取windows下的系统信息监控系统
Python用WMI模块获取Windows系统的硬件信息:硬盘分区、使用情况,内存大小,CPU型号,当前运行的进程,自启动程序及位置,系统的版本等信息。
PDF
29KB
2020-09-29 16:07
Python使用win32api获取Windows系统信息
本代码通过win32api库获取Windows系统的名称、计算机名、系统版本号等信息,并打印输出。import win32api# 获取Windows系统信息system_info = win
win32api 300
Python
2023-04-30 00:44
使用Python的WMI库获取Windows系统信息、硬盘信息和网卡信息的方法
Python的WMI库提供了一种简单的方法来获取Windows系统的各种信息,包括硬件信息和网络信息。通过使用Python和WMI,您可以获得Windows系统的各种详细信息,如系统版本、安装日期、C
docx
7.77KB
2023-06-09 04:01
使用Python获取Linux系统的各种信息
主要介绍了使用Python获取Linux系统的各种信息,例如系统类型、CPU信息、内存信息、块设备等,需要的朋友可以参考下
PDF
114KB
2020-10-28 06:55
使用Python获取Linux系统信息的代码
使用 Python 获取 Linux 系统信息的代码
PDF
158.05 KB
2020-10-28 06:55