Answers for "how to create a folder dynamically in python"

3

create a directory python

#creates a directory without throwing an error
import os
def create_dir(dir):
  if not os.path.exists(dir):
    os.makedirs(dir)
    print("Created Directory : ", dir)
  else:
    print("Directory already existed : ", dir)
  return dir
Posted by: Guest on July-25-2020
-1

how to add directory to python script

from pathlib import Path

basepath = Path('my_directory/')
files_in_basepath = basepath.iterdir()
for item in files_in_basepath:
    if item.is_file():
        print(item.name)
Posted by: Guest on June-17-2020

Code answers related to "how to create a folder dynamically in python"

Python Answers by Framework

Browse Popular Code Answers by Language