Os Makedirs
# Python2.x Python os.makedirs() Method
[ Python OS File/Directory Methods](#)
* * *
### Overview
The os.makedirs() method is used to recursively create directories.
If the subdirectory creation fails or already exists, it will raise an OSError exception. On Windows, Error 183 is the exception error for an existing directory.
If the first parameter `path` has only one level, it is the same as the [mkdir()](#) function.
### Syntax
The syntax for the **makedirs()** method is as follows:
os.makedirs(path, mode=0o777)
### Parameters
* **path** -- The directory to be created recursively. It can be a relative or absolute path.
* **mode** -- Permission mode.
### Return Value
This method does not return a value.
### Example
The following example demonstrates the use of the makedirs() method:
## Example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os,sys
# Directory to be created
path ="/tmp/home/monthly/daily"
os.makedirs( path,0755);
print"Path created"
Executing the above program outputs the following result:
Path created
[ Python OS File/Directory Methods](#)
YouTip