Try this blog, the use of the words will be completely abandoned after the CSDN, change this!
To use Python to get the memory information of the computer needs to use the Psutil module, the memory information that can be obtained is the total amount of memory, the total amount of available memory, the amount of memory used, the percentage of utilization, and other information.
Write a simple little script with the following code:
#!/usr/bin/python
Import Psutil
Pc_mem =psutil.virtual_memory ()
Div_gb_factor = (1024.0 * * 3)
Print ("Totalmemor:%FGB"% float (pc_mem.total/div_gb_factor))
Print ("availablememory:%FGB"% float (pc_mem.available/div_gb_factor))
Print ("usedmemory:%GB"% float (pc_mem.used/div_gb_factor))
Print ("Percentof used memory:%f"% float (pc_mem.percent))
Print ("FREEMEMORY:%FGB"% float (pc_mem.free/div_gb_factor))
The results of the program operation are as follows;
In [1]:%runos_mem.py
Total MEMOR:15.868237GB
Available MEMORY:13.069672GB
Used memory:2.79856b
Percent of usedmemory:17.600000
Freememory:13.069672gb
My computer is equipped with 16G of memory, also does not open how much to eat memory more severe applications. The general situation should be about the same, and there is no need to look at the task Manager to see the specific information.
Python shipping Koriyuki Gets the memory information of the operating system