How does mkdir -p work in Python?

PythonServer Side ProgrammingProgramming

mkdir -p is used to allow creating recursive directory making even if parent exists. To create a directory recursively, provide the path you want to create to the os.makedirs(path). To create a directory recusrively, you need to specify exists_ok as True to allow existing folders.

>>> import os
>>> os.makedirs('my_folder/another/folder', exists_ok=True)
raja
Published on 22-Dec-2017 08:27:14
Advertisements