首页 > 系统相关 >Python 获取windows硬件信息 CPU/计算机名/IP

Python 获取windows硬件信息 CPU/计算机名/IP

时间:2022-11-08 13:22:06浏览次数:47  
标签:CPUINFO platform Python IP cpu 获取 windows import CPU

获取windows硬件信息

# -*- coding: utf-8 -*-
# @Time    : 2022/11/8 11:22
# @Author  : lzc
# @Email   : [email protected]
# @blog    : https://www.cnblogs.com/zichliang
# @File    : getInfo.py
# @Software: PyCharm
import os
import platform
import socket
import getpass
import wmi

# 获取计算机名
hostname = socket.gethostname()  # platform.uname().node

# 获取用户名
username = getpass.getuser()

# 获取本地内网IP
ip = socket.gethostbyname(hostname)

# 获取你所使用的系统名称
system_name = platform.system()  # platform.uname().system

# 获取操作系统的位数
bit_ar = platform.architecture()

# 获取你所在文件夹
pwd = os.getcwd()

# 获取的你的CPU核心数以及CPU型号
c = wmi.WMI()


def get_cpu_info():
    CPUINFO = {}
    for cpu in c.Win32_Processor():
        # CPU ID 序列号
        # print("cpu id:", cpu.ProcessorId.strip())
        CPUINFO["CpuType"] = cpu.Name
        CPUINFO["CpuCores"] = cpu.NumberOfCores
        return CPUINFO


# 获取MAC和IP地址
def get_mac_info():
    ADDRESS = []
    for interface in c.Win32_NetworkAdapterConfiguration(IPEnabled=True):
        ADDRESS.append(interface.IPAddress)
    return get_cpu_info()

标签:CPUINFO,platform,Python,IP,cpu,获取,windows,import,CPU
From: https://www.cnblogs.com/zichliang/p/16869367.html

相关文章