官网地址:
Win32_LogicalDisk
查看本地磁盘信息
import wmi
def get_disk_info():
info_ = []
myWmi = wmi.WMI()
for disk in myWmi.Win32_LogicalDisk():
info = {"diskName":disk.DeviceID,"freeSizes":int(int(disk.FreeSpace)/1024/1024),"totalSizes":int(int(disk.Size)/1024/1024)}
info_.append(info)
return info_
Win32_DiskDrive
import wmi
def get_disk_info():
tmplist = []
c = wmi.WMI()
for physical_disk in c.Win32_DiskDrive():
tmpdict ={}
tmpdict["capcity"] = int(physical_disk.Size)/1024
tmpdict["name"] = physical_disk.Caption
tmplist.append(tmpdict)
return {"result":tmplist}