[Tutor] strip and split?

richard kappler richkappler at gmail.com
Sat Nov 30 19:40:00 CET 2013


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, but that's
where I'm floundering. Might I get a little guidance on this please?

regards, Richard

-- 

*Mater tua criceta fuit, et pater tuo redoluit bacarum sambucus*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131130/e8c2efa0/attachment.html>


More information about the Tutor mailing list