Skip to main content
improved formatting
Source Link
Georgy
  • 14k
  • 7
  • 69
  • 80

Check os.makedirsos.makedirs: (It makes sure the complete path exists.)
To handle the fact the directory might exist, catch OSErrorOSError. (If exist_okexist_ok is FalseFalse (the default), an OSErrorOSError is raised if the target directory already exists.)

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check os.makedirs: (It makes sure the complete path exists.)
To handle the fact the directory might exist, catch OSError. (If exist_ok is False (the default), an OSError is raised if the target directory already exists.)

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check os.makedirs: (It makes sure the complete path exists.)
To handle the fact the directory might exist, catch OSError. (If exist_ok is False (the default), an OSError is raised if the target directory already exists.)

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check out os.makedirs: (It makes sure the complete path exists.) To
To handle the fact the directory might exist, catch OSError. (If exist_ok is False (the default), an OSError is raised if the target directory already exists.)

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check out os.makedirs: (It makes sure the complete path exists.) To handle the fact the directory might exist, catch OSError.

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check os.makedirs: (It makes sure the complete path exists.)
To handle the fact the directory might exist, catch OSError. (If exist_ok is False (the default), an OSError is raised if the target directory already exists.)

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check out os.makedirsos.makedirs: (It makes sure the complete path exists.) To handle the fact the directory might exist, catch OSError.

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check out os.makedirs: (It makes sure the complete path exists.) To handle the fact the directory might exist, catch OSError.

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass

Check out os.makedirs: (It makes sure the complete path exists.) To handle the fact the directory might exist, catch OSError.

import os
try:
    os.makedirs('./path/to/somewhere')
except OSError:
    pass
Source Link
Douglas Mayle
  • 21.9k
  • 10
  • 45
  • 58
Loading