how to check if a directory exists or not using python

Solutions on MaxInterview for how to check if a directory exists or not using python by the best coders in the world

showing results for - "how to check if a directory exists or not using python"
Damián
17 Oct 2017
1import os.path
2from os import path
3
4def main():
5
6   print ("File exists:"+str(path.exists('guru99.txt')))
7   print ("File exists:" + str(path.exists('career.guru99.txt')))
8   print ("directory exists:" + str(path.exists('myDirectory')))
9
10if __name__== "__main__":
11   main()