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 9,351 times
3
Amit Kumar Gupta
- 15,516
- 6
- 43
- 60
gowtham
- 167
- 1
- 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,289
- 1
- 23
- 31
Fallen Angel
- 31
- 1