Path.mkdir(mode=0o777, parents=False, exist_ok=False)
Create a new directory at this given path. If mode is given, it is combined with the process’ umask
value to determine the file mode and access flags. If the path already exists, FileExistsError
is raised.
If parents is true, any missing parents of this path are created as needed; they are created with the default permissions without taking mode into account (mimicking the POSIX mkdir -p
command).
If parents is false (the default), a missing parent raises FileNotFoundError
.
If exist_ok is false (the default), an FileExistsError
is raised if the target directory already exists.
If exist_ok is true, FileExistsError
exceptions will be ignored (same behavior as the POSIX mkdir -p
command), but only if the last path component is not an existing non-directory file.
Changed in version 3.5: The exist_ok parameter was added.
Please login to continue.