Tuesday, 21 September 2021

Python: rmtree: Delete a directory with content

To delete a directory with content use the method ‘rmtree’ from shutil module.

 

remove_dir_with_content.py

import shutil

path = '/Users/Shared/data'
shutil.rmtree(path)

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment