I have a sort of a dictionary resulting from psutil.disk_usage('/') that tells me info about my hard drive, specifically:
usage(total=147491323904, used=62555189248, free=77443956736, percent=42.4) I'm having a bit of a brain fudge here and can't remember how to strip out what I want. All I want to end up with is the number percent (in this case 42.4) I started playing with .strip but the usage term before the parens gets in the way. If it weren't for that I could convert this into a dict and just pull the number by the key, right? So how do I strip out the 'usage' string? Once I do that, I think I know what I'm doing but here's my proposed code to look at if you would. import psutil as ps disk = ps.disk_usage('/') # whatever I need to do to strip usage out d = {} for item in disk.split(','): item = item.strip() key, value = item.split(':') key = key.strip() value = value.strip() d[key] = float(value) return d Mind you, this is as of yet untested code, so before you ask for tracebacks, I can't give any until I figure out how to get rid of the preceding 'usage'. regards, Richard -- quando omni flunkus moritati
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor