On Linux: from pathlib import Path Path("/dir1/dir2/dir3").mkdir(parents=True, exist_ok=True)12from pathlib import PathPath("/dir1/dir2/dir3").mkdir(parents=True, exist_ok=True) On Windows: from pathlib import Path Path(“C:\dir1\dir2\dir3”).mkdir(parents=True, exist_ok=True)12from pathlib import PathPath(“C:\dir1\dir2\dir3”).mkdir(parents=True, exist_ok=True)

Here:

parents=True: instruct to create parent directories if not available. exist_ok=True: Do not throw an error if a directory already exists.

Execute the above Python script and checked for the newly created directory tree.