Note: This Code requires support for wmi and system win32 extensions. Without the installation library to download the installation, I installed WMI-1.4.6.win32 and pywin32-218.win32-py2.7... note: this code requires wmi and system win32 extension support.
No installation library to download the installation, I installed WMI-1.4.6.win32 and pywin32-218.win32-py2.7
Also, modify the file directory in the code.
#-*-Coding: gb2312-*-import wmihardware = file ('F: \ Python \ Hardware.txt ', 'w') w = wmi. WMI () hardware. write ("cpu model, clock speed: \ n") for processor in w. win32_Processor (): hardware. write ("Processor ID: % s" % processor. deviceID) hardware. write ("\ nProcess Name: % s" % processor. name. strip () + '\ n \ n') hardware. write ('memory size: ') totalMemSize = 0for memModule in w. win32_PhysicalMemory (): totalMemSize + = int (memModule. capacity) hardware. write ("\ nMemory Capacity: %. 2fMB "% (totalMemSize + 1048575)/1048576) + '\ n \ n') hardware. write ('Hard disk usage: ') for disk in w. win32_LogicalDisk (DriveType = 3): temp = disk. caption + "% 0.2f % free" % (100.0 * long (disk. freeSpace)/long (disk. size) hardware. write ('\ n' + temp) hardware. write ('\ n') hardware. write ('\ n display IP address and MAC: \ n') for interface in w. win32_NetworkAdapterConfiguration (IPEnabled = 1): hardware. write ('Nic driver information: ') hardware. write (interface. description + '\ n') hardware. write ('Nic MAC address: ') hardware. write (interface. MACAddress + '\ n') # for ip_address in interface. IPAddress: hardware. write ('IP Address: ') hardware. write (interface. IPAddress [0] + '\ n') hardware. write ('internet IP interface ') hardware. write (interface. IPAddress [1] + '\ n') hardware. close ()
Run