os.makedirs()

os.makedirs(name, mode=0o777, exist_ok=False)

Recursive directory creation function. Like mkdir(), but makes all intermediate-level directories needed to contain the leaf directory.

The mode parameter is passed to mkdir(); see the mkdir() description for how it is interpreted.

If exist_ok is False (the default), an OSError is raised if the target directory already exists.

Note

makedirs() will become confused if the path elements to create include pardir (eg. ”..” on UNIX systems).

This function handles UNC paths correctly.

New in version 3.2: The exist_ok parameter.

Changed in version 3.4.1: Before Python 3.4.1, if exist_ok was True and the directory existed, makedirs() would still raise an error if mode did not match the mode of the existing directory. Since this behavior was impossible to implement safely, it was removed in Python 3.4.1. See issue 21082.

doc_python
2016-10-07 17:39:16
Comments
Leave a Comment

Please login to continue.