create a directory in python

To create a directory in Python, you can use the mkdir() function from the os module. Here is the code snippet to create a directory:

main.py
import os

# Name of the directory to be created
directory = "example_directory"

# Create the directory
os.mkdir(directory)
125 chars
8 lines

In the above code, os.mkdir(directory) creates a directory with name example_directory. You can replace the value of the directory variable with the name of the directory you want to create.

gistlibby LogSnag