directory

Chris Liechti cliechti at gmx.net
Tue Jun 4 20:44:12 CEST 2002


Gold Fish <occeanlinux at linuxmail.org> wrote in
news:3cfcfd4a_1 at news.iprimus.com.au: 

> How to read the subdirectories in the directory
> Support i have the directory /home/ which have some subdirectories
> /home/sub1
> /home/sub2
> /home/sub3
> I am using os.listdir('/home/') to read in the list so it will be 
> ['sub1','sub2','sub3'] now i want to read inside the sub directory
> sub2 once again i using os.listdir(os.listdir('/home/')[1]) but it
> came out with an errors: not a file or directory. Can anyone tell me
> what did i wrong. Anh how to fix it.

(probably because os.listdir returns only file-/diectorynames and not 
paths)

look at os.path.walk(), it's there to solve your problem ;-)

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list