Answers for "python delete folder if exists"

36

python os remove file

import os
os.remove("filename.txt")
Posted by: Guest on February-11-2020
9

python dlete folder

import shutil

shutil.rmtree('/folder_name')
Posted by: Guest on June-12-2020
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 folder if exists"

Python Answers by Framework

Browse Popular Code Answers by Language