How to Delete an Entire Folder in Python


In this example we will show how to delete an entire folder in Python.

Source Code

import os

os.rmdir("del-folder") 

Output:

If the folder exists, delete it without prompting.
If the folder does not exist, a 'FileNotFoundError' error is thrown.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments