Zygimantas Zygimantas - 3 months ago 11
Python Question

How do I delete a file or folder in Python?

How do I delete a file or folder in Python?

I am using the Python scripting language running on the Windows XP operating system.

Answer

os.remove() will remove a file.

os.rmdir() will remove an empty directory.

shutil.rmtree() will delete a directory and all its contents.