What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried:
You can use os.listdir for this:
os.listdir
import os if 'dirName' in os.listdir('parentFolderPath') print('Directory Exists')