Jan-13-2017, 07:39 PM
Hello
Below is an example from a book called Automating the boring stuff with Python.
This code is supposed to deletes all files that end with .txt in a directory:
But it doesn't work.
Can someone tell what is the problem.
Thanks
Below is an example from a book called Automating the boring stuff with Python.
This code is supposed to deletes all files that end with .txt in a directory:
Quote:import os
for filename in os.listdir("C:\\dir"):
if filename.endswith('.txt'):
os.unlink(filename)
But it doesn't work.
Can someone tell what is the problem.
Thanks