import os # check the if the path is a directory print(os.path.isdir("path")) # check if the path is a file print(os.path.isfile("path"))