import osdirpath = "<dirpath>" # Replace the "<dirpath>" with actual directory path.
if os.path.exists(dirpath):print("Directory exist")else: #this is optional if you want to create a directory if doesn't exist.os.mkdir(dirpath):print("Directory created")
import os.pathfrom os import path
def main():
print ("File exists:"+str(path.exists('your_file.txt')))print ("Directory exists:" + str(path.exists('myDirectory')))print("Item is a file: " + str(path.isfile("your_file.txt")))print("Item is a directory: " + str(path.isdir("myDirectory")))
if __name__== "__main__":main()