N/APosted on - 11/16/2012
Is there a python file eraser? My friend is using python programming language for building an important program or system; she asks me if I have any idea about the python file eraser. I want to help my friend to research about this. Share with me your answers and ideas.
Is there a python file eraser?
Your question is somewhat unclear. But assuming that you were trying to find some method to delete files using Python, here are a couple of methods you can follow.
You can do use the remove () function from the module 'OS'
Or try this code below.
if dir[-1] == os.sep: dir = dir[:-1]
files = os.listdir(dir)
for file in files:
if file == '.' or file == '..': continue
path = dir + os.sep + file
Hope this will fix it.