import os
path = "./sample"
os.path.exists(path)
Now you can see the existence of a file or directory named sample.
By the way, if you want to check only the files without including the directory,
os.path.isfile(path)
If you don't want to include files and just want to see the directory
os.path.isdir(path)
Can be done with
Recommended Posts