Answers for "python delete directory and contents if 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 delete directory and contents if exists"

Python Answers by Framework

Browse Popular Code Answers by Language