SRP
SRP

Reputation: 21

How to get RAM Usage percentage in Python?

Now I know there's psutil module for the use:

import psutil
a=psutil.virtual_memory()
print(a)

And it shows this output:

svmem(total=4238442496, available=1836089344, percent=56.7, used=2402353152, free=1836089344)

It has got percentage, but I only want percentage of RAM usage without all other features like used, free, etc. Is it possible ? Please sort this out. Thanks in advance for answers.

Upvotes: 1

Views: 628

Answers (1)

Devansh Soni
Devansh Soni

Reputation: 771

Just a minor change:

import psutil

a = psutil.virtual_memory()
print(a.percent) # Here's a change

Hope this helps :)

Upvotes: 2

Related Questions