I am trying to write some code for finding and deleting hidden files in many folders. The file I want to remove is called "desktop". Where do I need to write the file name? I don't know how to continue from this point. Also, I get the error: Illegal target for variable annotation
import os, fnmatch
def find(pattern,path):
result=[]
for root, dirs, files in os.walk(path):
for name in files:
in fnmatch.fnmatch(name,pattern):
result.append(os.path.join(root,name))
return result
res= find('*.ini', r'C:Users...')
print(res)
for file in res:
os.remove(file)
question from:
https://stackoverflow.com/questions/65649109/find-and-delete-file-in-multiple-folders-getting-an-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…