On Nov 30, 2013, at 1:40 PM, richard kappler wrote:

> I'm using psutil to generate some somatic data with the following script:
> 
> import psutil as ps
> 
> cpu = ps.cpu_percent()
> mem = ps.virtual_memory()
> disk = ps.disk_usage('/')
> 
> All works well, but except for cpu I am struggling to learn how to strip out 
> what I don't need.
> 
> For example, once I do the above, if I then enter "disk" I get:
> 
> disk usage(total=302264549376, used=73844322304, free=213066088448, 
> percent=24.4)
> 
> So if I want only the number following percent, I get that I need to convert 
> this to a built in type and do some split and strip

You could take that approach, but you might find that this one is easier:

>>> psutil.disk_usage('/')[-1:][0]
91.2

Take care,
Don

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to