Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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?
C:\sample\sample1\hello.py
sample
hello.py
The following functions may help:
Add a comment
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))
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.