Create a full path with os.makedirs()

EasyOS Module Programs · 32 of 49

Write a Python program to create every folder of a path with os.makedirs().

Advertisement
Output
True

Approach

  1. exist_ok=True makes repeated runs safe.

Solution

Python
import os os.makedirs("a/b/c/d", exist_ok=True)os.makedirs("a/b/c/d", exist_ok=True)print(os.path.isdir("a/b/c/d"))
Output
True

Learn the concept

New to this topic? Read the lesson, then come back.

More os module programs

← All 49 OS Module Programs

Leave a Comment