The mkdir method of os the module
The mkdir method creates a single folder. The first parameter of the method specifies the path to the folder, the second optional parameter specifies the access mode to it. The third optional parameter specifies the file descriptor referring to the folder, its default value is None. The method returns the value None. If the folder already exists, the method returns the FileExistsError exception.
Syntax
import os
os.mkdir(path to folder, [access mode], [file descriptor])
Example
Let's create a new folder dir1:
import os
os.mkdir('dir1/')
See also
-
method
removeof moduleos,
which deletes the file -
method
getcwdmoduleos,
which returns the current working directory -
method
listdirof moduleos,
which returns a list of files in the working directory -
method
makedirsof moduleos,
which creates folders -
method
mkdirof moduleos,
which creates one folder -
method
renameof moduleos,
which renames a file and folder -
method
rmtreeof moduleshutil,
which recursively deletes a folder -
method
copytreeof moduleshutil,
which recursively copies a folder