How can I make a verify error for this command?
if blablablabla:
os.makedirs('C:\\test\\')
If the folder already exists, he return me an error... how can I make it ignore this error? and move on ?
How can I make a verify error for this command?
if blablablabla:
os.makedirs('C:\\test\\')
If the folder already exists, he return me an error... how can I make it ignore this error? and move on ?
try:
os.makedirs('C:\\test\\')
except OSError:
pass
You also might want to check the specific "already exists" error (since OSError
could mean other things, like permission denied...
import errno
try:
os.makedirs('C:\\test\\')
except OSError as e:
if e.errno != errno.EEXIST:
raise # raises the error again