0 works

Create a nested directory in Python 3.5+

dashboard+ Project

Posted by @bravocoder #python

Code snippet:

import pathlib
pathlib.Path('/my/directory').mkdir(parents=True, exist_ok=True) 
content_copyCopy to Clipboard

More details:

pathlib.Path.mkdir recursively creates the directory and does not raise an exception if the directory already exists. If you don't need or want the parents to be created, skip the parents argument.

Code snippet source:


>> Browse more code snippets