How to delete files and folders in python
steps to delete files and folder using python
Delete files
import os
path = '/file_name'
if os.path.exists(path):
os.remove(path)
Delete empty folders
import os
path = '/folder_name'
if os.path.exists(pathe):
os.remdir(path)
Delete folders with files
import shutil
path = '/folder_name'
if os.path.isdir(path):
shutil.rmtree(path)