Step to delete a File or Folder in Python

Sometime we have to delete a file or folder/directory in python. Either its empty or contain anything, please find the following steps,

Step to delete a File or Folder in Python

To remove a file:
os.remove()

To remove an empty directory/folder:
os.rmdir()

To remove a directory and all its contents:
shutil.rmtree()

The following two tabs change content below.
I am Karthik, software engineer by profession. You can find and follow me, from Social Media or here. Google+

Latest posts by karsho (see all)

This entry was posted in General, Python.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please Fill this Sum * Time limit is exhausted. Please reload the CAPTCHA.