class MEMORYSTATUSEX(ctypes.Structure):
    _fields_ = [('dwLength', ctypes.c_ulong), ('dwMemoryLoad', ctypes.
        c_ulong), ('ullTotalPhys', ctypes.c_ulonglong), ('ullAvailPhys',
        ctypes.c_ulonglong), ('ullTotalPageFile', ctypes.c_ulonglong), (
        'ullAvailPageFile', ctypes.c_ulonglong), ('ullTotalVirtual', ctypes
        .c_ulonglong), ('ullAvailVirtual', ctypes.c_ulonglong), (
        'sullAvailExtendedVirtual', ctypes.c_ulonglong)]

def __init__(self):
    self.dwLength = ctypes.sizeof(self)
super(MEMORYSTATUSEX, self).__init__()
stat = MEMORYSTATUSEX()
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
print('MemoryLoad: %d%%' % stat.dwMemoryLoad)
Get memory usage of computer in Windows with Python