Python3 Os Makedirs
# Python3.x Python3 os.makedirs() Method
[ Python3 OS File/Directory Methods](#)
* * *
### Overview
The os.makedirs() method is used to recursively create multiple directories.
If the creation of a subdirectory fails or it already exists, an OSError exception will be raised. On Windows, Error 183 is the exception error indicating that the directory already exists.
If the first argument `path` has only one level, meaning it only creates a single directory, then it is the same as the [mkdir()](#) function.
### Syntax
The syntax format for the **makedirs()** method is as follows:
os.makedirs(name, mode=511, exist_ok=False)
### Parameters
* **path** -- The directory to be created recursively. It can be a relative or absolute path.
* **mode** -- The permission mode. The default mode is 511 (octal).
* **exist_ok**: Whether to trigger an exception if the directory already exists. If `exist_ok` is False (the default), a FileExistsError exception is triggered if the target directory already exists; if `exist_ok` is True, no FileExistsError exception is triggered if the target directory already exists.
### Return Value
This method does not return a value.
### Example
The following example demonstrates the use of the makedirs() method:
## Example
#!/usr/bin/python3
import os,sys
# Directory to be created
path ="/tmp/home/monthly/daily"
os.makedirs( path,0o777);
print("The path was created")
Executing the above program outputs the following result:
The path was created
[ Python3 OS File/Directory Methods](#)
YouTip