Computer >> Computer tutorials >  >> Programming >> Python

How to create a directory recursively using Python?


To create a directory recursively, provide the path you want to create to the os.makedirs(path). To create a directory recursively, you need to specify exists_ok as True to allow existing folders.

import os
os.makedirs('my_folder/another/folder', exists_ok=True)