import win32com.client
objSWbemServices = win32com.client.Dispatch(
"WbemScripting.SWbemLocator").ConnectServer(".","root\cimv2")
for item in objSWbemServices.ExecQuery(
"SELECT * FROM Win32_PnPEntity "):
found=False
for name in ('Caption','Capabilities '):
a = getattr(item, name, None)
if a is not None:
b=('%s,' %a)
if "Item" in b:
print "found"
found = True
else:
print "Not found"
break
「見つかった」「見つからない」を一度だけ表示したい