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