parsing a file [newbie]
Grant Edwards
grante at visi.com
Wed Jan 17 17:27:37 EST 2001
In article <mailman.979728198.29644.python-list at python.org>, Langa Kentane wrote:
>ONe thing I don't understand.
>When I run os.popen('df -h'), this returns a pointer to an already open file
>if I am not mistaken.
Correct.
>Now, to apply what you gave me to this scenario, how would I go about it.
You call the read() or readlines() method of that file object.
Something like this:
import os
import string
x = os.popen("mount").readlines()
y = []
for line in x:
words = string.split(line)
if len(words) >= 3:
y.append(words[2])
--
Grant Edwards grante Yow! .. are the STEWED
at PRUNES still in the HAIR
visi.com DRYER?
More information about the Python-list
mailing list