Archive for December, 2011

How to Delete Files Using Python Code

It’s really easy to delete a single file in Python. Say the file you want to delete is called “MyFile.txt.” You could delete it using this syntax:

import os
 
os.remove("MyFile.txt")

Let’s say you had many files in a directory, and the ones you wanted to delete were called MyFile1.txt, MyFile2.txt, and MyFile3.txt. One trick that you can use [...] Read more »