Create a directory or folder in Python

To create a new folder, use mkdir() in os module.

import os


The new_folder directory is created in the directory that has the current Python file. The second argument of mkdir() is the permission mode and the default value is 0o777.

import os

os.mkdir('new_dir', 664)

Python File

Python Tutorial