March 4, 2024
To create a new directory Python has a function mkdir( ) built into os module.

To create a new directory Python has a function mkdir( ) built into os module.

Syntax

os.mkdir('name')

Where name is the directory to be created in the current working location.

Example

>>> import os
>>> os.mkdir('abc') #create a directory abc in current directory
>>> os.mkdir('C:/abc') #create a direcotry abc in C:

Note: Use the forward slash / while creating directories in another location.