Answers for "python remove a directory if it exists"

0

python delete directory if exists

import os
import shutil

dirpath = os.path.join('dataset3', 'dataset')
if os.path.exists(dirpath) and os.path.isdir(dirpath):
    shutil.rmtree(dirpath)
Posted by: Guest on July-20-2021

Code answers related to "python remove a directory if it exists"

Python Answers by Framework

Browse Popular Code Answers by Language