Os Mkdir
# Python2.x Python os.mkdir() Method
[ Python OS File/Directory Methods](#)
* * *
### Overview
The os.mkdir() method is used to create a directory (single-level directory) with a numeric permission mode. The default mode is 0777 (octal).
If the directory has multiple levels, only the last level is created. If any parent directory of the last level does not exist, an OSError will be raised.
### Syntax
The syntax for the **mkdir()** method is as follows:
os.mkdir(path[, mode])
### Parameters
* **path** -- The directory to be created. Can be a relative or absolute path.
* **mode** -- The numeric permission mode to set for the directory.
### Return Value
This method does not return a value.
### Example
The following example demonstrates the use of the mkdir() method:
## Example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os,sys
# Directory to be created
path ="/tmp/home/monthly/daily/hourly"
os.mkdir( path,0755);
print"Directory created"
Executing the above program produces the following output:
Directory created
[ Python OS File/Directory Methods](#)
YouTip