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?
Asked
Active
Viewed 1.0k times
4

Amit Kumar Gupta
- 17,184
- 7
- 46
- 64

gowtham
- 51
- 2
- 2
- 4
2 Answers
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))

TarasB
- 2,407
- 1
- 24
- 32

Fallen Angel
- 31
- 1