xxxxxxxxxx
import shutil
shutil.rmtree('/folder_name')
xxxxxxxxxx
>>> os.listdir()
['new_one', 'old.txt']
>>> os.remove('old.txt')
>>> os.listdir()
['new_one']
>>> os.rmdir('new_one')
>>> os.listdir()
[]
xxxxxxxxxx
import shutil
shutil.rmtree(r'Path where the folder with its files is stored\Folder name')
xxxxxxxxxx
We can use functions from Python’s built-in os module to delete files and empty folders.
os.remove() will delete a file.
os.rmdir() will delete an empty folder.
To delete a folder that is not empty, we must use the rmtree() function from Python’s shutil module.
https://sentry.io/answers/delete-a-file-or-folder-in-python/