def getPnpDeviceInfo():
c = wmi.WMI()
wql = "SELECT * FROM Win32_PnPEntity WHERE Manufacturer != 'Microsoft' AND NOT PNPDeviceID LIKE 'ROOT\\%'"
print ("All physical PNP devices")
for J in c.query(wql):
print(J)
Cette fonction (la requête) retourne généralement tous les appareils PNP physiques, voici un échantillon de sortie:Comment extraire un attribut particulier de l'instance de Win32_PnPEntity?
instance of Win32_PnPEntity
{
Caption = "ACPI Lid";
ClassGuid = "{4d36e97d-e325-11ce-bfc1-08002be10318}";
ConfigManagerErrorCode = 0;
ConfigManagerUserConfig = FALSE;
CreationClassName = "Win32_PnPEntity";
Description = "ACPI Lid";
DeviceID = "ACPI\\PNP0C0D\\2&DABA3FF&3";
HardwareID = {"ACPI\\PNP0C0D", "*PNP0C0D"};
Manufacturer = "(Standard system devices)";
Name = "ACPI Lid";
PNPDeviceID = "ACPI\\PNP0C0D\\2&DABA3FF&3";
Status = "OK";
SystemCreationClassName = "Win32_ComputerSystem";
SystemName = "SUSDUTTA-LAP";
};
La question est, si je veux extraire juste le « PNPDeviceID » de l'instance, comment le faire en python, sans changer le WQL?