Mega Code Archive

 
Categories / Python Tutorial / Buildin Module
 

List directories

import os import os.path sPath = raw_input("Enter the path: ") if sPath[len(sPath)-1] != '\\' :     sPath += '\\' eList = os.listdir(sPath) for e in eList :     if os.path.isdir(sPath + e) :         print "Directory: " + e