How do you conver output of "popen('ls')" to a list?
Trent Mick
trentm at ActiveState.com
Wed Feb 20 17:08:06 EST 2002
More information about the Python-list mailing list
Wed Feb 20 17:08:06 EST 2002
- Previous message (by thread): How do you conver output of "popen('ls')" to a list?
- Next message (by thread): How do you conver output of "popen('ls')" to a list?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
$ ls
bye.txt hello.txt
$ python
>>> import os
>>> o = os.popen('ls')
>>> lines = o.readlines()
>>> o.close()
>>> lines
['bye.txt\012', 'hello.txt\012']
>>> files = [line.strip() for line in lines] # strip off EOL characters
>>> files
['bye.txt', 'hello.txt']
>>>
Cheers,
Trent
--
Trent Mick
TrentM at ActiveState.com
- Previous message (by thread): How do you conver output of "popen('ls')" to a list?
- Next message (by thread): How do you conver output of "popen('ls')" to a list?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list