- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to delete a Python directory effectively?
If you want to remove an empty folder, you can call the rmdir function in os module.
example
>>> import os >>> os.rmdir('my_folder')
If you want to delete a folder containing all files you want to remove, you can remove the folder as follows −
>>> import shutil >>> shutil.rmtree('my_folder')
- Related Articles
- How to delete multiple files in a directory in Python?
- How to delete all files in a directory with Python?
- Delete a directory in Java
- Java Program to delete file or directory
- How to create a directory using Python?
- How to remove a directory using Python?
- How to disable delete permission of File and Directory in Linux?
- Using Iterations in Python Effectively
- How to create a directory recursively using Python?
- How to remove a directory recursively using Python?
- How to calculate a directory size using Python?
- How to check if a given directory contains any other directory in Python?
- How to Manage Project Stakeholders Effectively?
- How to delete a file using Python?
- How to rename directory using Python?

Advertisements