Alex Rivera | Logout

How to delete the contents of a folder?

Asked 2008-10-09T04:22:33.817
865

How can I delete the contents of a local folder in Python?

The current project is for Windows, but I would like to see *nix also.

Edit
Report

1 Answer

18

I used to solve the problem this way:

import shutil
import os

shutil.rmtree(dirpath)
os.mkdir(dirpath)
answered 2013-06-17T11:52:24.243

Your Answer