获取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