Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

os.makedirs

import os

directory = "ihritik"

parent_dir = "/home/User/Documents/GeeksForGeeks/Authors"

path = os.path.join(parent_dir, directory)

os.makedirs(path)
Comment

Examples of os.makedirs() method

# Python program to explain os.makedirs() method
   
# importing os module
import os
 
# Leaf directory
directory = "ranjeet"
 
# Parent Directories
parent_dir = "/home/User/Documents/Softhunt/Authors"
 
# Path
path = os.path.join(parent_dir, directory)
 
# Create the directory
# 'ranjeet'
os.makedirs(path)
print("Directory '%s' created" %directory)
 
# Directory 'Softhunt' and 'Authors' will
# be created too
# if it does not exists
 

# Leaf directory
directory = "c"
 
# Parent Directories
parent_dir = "/home/User/Documents/Softhunt/a/b"
 
# mode
mode = 0o666
 
path = os.path.join(parent_dir, directory)
 
# Create the directory
# 'c'
  
os.makedirs(path, mode)
print("Directory '%s' created" %directory)
 

# 'Softhunt', 'a', and 'b'
# will also be created if
# it does not exists
# If any of the intermediate level
# directory is missing
# os.makedirs() method will
# create them
# os.makedirs() method can be
# used to create a directory tree
Comment

PREVIOUS NEXT
Code Example
Python :: stock market python 
Python :: how to print values without space in python 
Python :: change creation date filesystem py 
Python :: model.predict knn 
Python :: add element to array list python 
Python :: django get all model fields 
Python :: how to add string in csv in python 
Python :: python get bits from byte 
Python :: datetime64 ns to date python 
Python :: sum range 
Python :: Swap 2 items of a list in python 
Python :: tkinter auto resize height 
Python :: python lock file 
Python :: turtle python screen border 
Python :: python using end keyword 
Python :: python set workspace dir 
Python :: generating datafraoms using specific row values 
Python :: get hours from datetime.timedelta in python (Django) 
Python :: tkinter video 
Python :: string in python 
Python :: mean pandas 
Python :: check dictionary values pandas dataframe colu 
Python :: read variable in a string python 
Python :: duplicate a list with for loop in python 
Python :: pandas convert string to float 
Python :: identity matrix with numpy 
Python :: find type of an element in list python 
Python :: how to devided array into parts python 
Python :: load list from file python 
Python :: python web app 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =