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


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.