Create a nested directory in Python 3.5+

PHOTO EMBED

Saved by @bravocoder #python

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

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