Python – How to delete a file or folder in Python

delete-filedirectoryfile-iopython

How do I delete a file or folder in Python?

Best Solution


Path objects from the Python 3.4+ pathlib module also expose these instance methods: