# -*- coding: UTF-8 -*-
import wmi
c = wmi.WMI()
f = open('filename.txt', 'wt')
for p in c.Win32_MotherboardDevice():
for pname in sorted(p.properties.keys()):
f.write('%s: %s\n' % (pname, getattr(p, pname)))
f.write('-'*20+'\n')
Traceback (most recent call last):
File "C:\tmp\wmitest.py", line 10, in <module>
f.write('%s: %s\n' % (pname, getattr(p, pname)))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 9-19: ordinal not in range(128)
# -*- coding: UTF-8 -*-
import wmi
c = wmi.WMI()
for p in c.Win32_MotherboardDevice():
for pname in sorted(p.properties.keys()):
print '%s: %s' % (pname, getattr(p, pname))
print '-'*20
Availability: None
Caption: Материнская плата
ConfigManagerErrorCode: None
ConfigManagerUserConfig: None
CreationClassName: Win32_MotherBoardDevice
Description: Материнская плата
DeviceID: Motherboard
ErrorCleared: None
ErrorDescription: None
InstallDate: None
LastErrorCode: None
Name: Материнская плата
PNPDeviceID: None
PowerManagementCapabilities: None
PowerManagementSupported: None
PrimaryBusType: PCI
RevisionNumber: None
SecondaryBusType: ISA
Status: None
StatusInfo: None
SystemCreationClassName: Win32_ComputerSystem
SystemName: WIN1
# -*- coding: UTF-8 -*-
import wmi
c = wmi.WMI()
f = open('filename.txt', 'wt')
for p in c.Win32_MotherboardDevice():
f.write('%s\n' % getattr(p, 'Caption').encode('utf-8'))
# -*- coding: UTF-8 -*-
import wmi
c = wmi.WMI()
f = open('filename.txt', 'wt')
for p in c.Win32_MotherboardDevice():
for pname in sorted(p.properties.keys()):
val = getattr(p, pname)
if type(val) == unicode:
val = val.encode('utf-8')
else:
val = str(val)
f.write('%s: %s\n' % (pname, val))
f.write('\n\n')
Traceback (most recent call last):
File "C:\tmp\wmitest3.py", line 16, in <module>
f.write('%s: %s\n' % (pname, val))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
Python 2.5.4, OS - Windows XP SP3