5,337
edits
(→Usage) |
|||
Line 81: | Line 81: | ||
[https://stackoverflow.com/questions/12517451/automatically-creating-directories-with-file-output Reference] | [https://stackoverflow.com/questions/12517451/automatically-creating-directories-with-file-output Reference] | ||
<syntaxhighlight lang="python"> | <syntaxhighlight lang="python"> | ||
// Or os.makedirs(path, exist_ok=True) | |||
def ensure_dir_exists(dir_path): | def ensure_dir_exists(dir_path): | ||
if not os.path.exists(dir_path): | if not os.path.exists(dir_path): |