Mega Code Archive

 
Categories / Python Tutorial / File
 

Os path module provides exists(path), isdir(path), and isfile(path) to check for the existence of files and directories

import os print os.path.exists("/dir1") print os.path.isdir("/dir2") print os.path.isfile("/test.doc")