Listing Directories : Dircetories « File « Python






Listing Directories

Listing Directories

import os 

os.listdir("c:\\")                

dirname = "c:\\" 

os.listdir(dirname)                                

print [f for f in os.listdir(dirname) if os.path.isfile(os.path.join(dirname, f))]        [3] 

print [f for f in os.listdir(dirname) if os.path.isdir(os.path.join(dirname, f))]            [4] 


           
       








Related examples in the same category

1.Listing Directories with glob
2.Change Dir
3.Working with DirectoriesWorking with Directories