Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python create directory if non existent

import os
if not os.path.exists('my_folder'):
    os.makedirs('my_folder')
    
#You can also use the python idiom EAFP: 
#Easier to ask for forgiveness than permission. For example,

try:
    os.makedirs('my_folder')
except OSError as e:
    if e.errno != errno.EEXIST:
        raise
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #python #create #directory #existent
ADD COMMENT
Topic
Name
5+9 =