0 works

Create a nested directory in Python 3.5+


dashboard

Posted by @bravocoder #python

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

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.

https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory-in-python

>> Browse more code snippets

more_vert