Latest web development tutorials

Python os.mkdir () method

Python File (File) method Python OS file / directory methods


Outline

os.mkdir () method is used to model the digital rights to create a directory. The default mode is 0777 (octal).

grammar

mkdir () method syntax is as follows:

os.mkdir(path[, mode])

parameter

  • path - the directory to be created

  • mode - authority digital mode To set directory

return value

This method has no return value.

Examples

The following example demonstrates mkdir () method of use:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, sys

# 创建的目录
path = "/tmp/home/monthly/daily/hourly"

os.mkdir( path, 0755 );

print "目录已创建"

The above program output is:

目录已创建

Python File (File) method Python OS file / directory methods