[Python] Check Folder or File Exists
Function to check if a folder exists or not.
import os
if os.path.isdir('path_to_folder'):
print("exists")
else:
print("Not")
Function to check file:
import os
if os.path.exists(os.path.join('folder_path', 'file_name.txt')):
print("exists")
else:
print("Not")
Post a Comment