
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 remove a directory using Python?
If you want to remove an empty folder, you can call the rmdir function in os module.
For 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 Questions & Answers
- How to remove a directory recursively using Python?
- How to create a directory using Python?
- How to create a directory recursively using Python?
- How to calculate a directory size using Python?
- How to rename directory using Python?
- How to create a unique directory name using Python?
- How to change current directory using Python?
- How to copy files to a new directory using Python?
- How to remove a file using Python?
- How to check the permissions of a directory using Python?
- How to change the permission of a directory using Python?
- How to change the owner of a directory using Python?
- How to create a zip archive of a directory using Python?
- How to create a directory using Java?
- How to create a Directory using C#?
Advertisements