5

I want to create a path like C:\sample\sample1\hello.py. It should automatically create the complete path from sample to hello.py, and all the directories in between. Is this possible in Python?

0

2 Answers 2

6

The following functions may help:

Sign up to request clarification or add additional context in comments.

Comments

2
import os
root_path = 'C:\path'

folders = ['folder 01', 'folder 02', 'folder 03']

for folder in folders:

    os.mkdir(os.path.join(root_path, folder))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.