import os if not os.path.exists('parentdirectory/mydirectory'): os.makedirs('parentdirectory/mydirectory')