Skip to content

Remove files and directories

To remove files and directories, there are 3 commands:

  • to remove a file, use os.remove()
  • To remove an empty directory, use os.rmdir()
  • To remove a directory and all it’s contents (in other words, delete recursively), use shutil.rmtree

[sc name=”src” url=”https://stackoverflow.com/questions/6996603/how-to-delete-a-file-or-folder” ]

Be First to Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.