os.remove() is to remove a file. os.rmdir() is to remove an empty directory. shutil.rmtree() is to delete a directory and all its contents. shutil.rmtree(dirpath)