import os
import time
path = "F:\\zjbg" #文件夹路径
suffix = ".html" #需要删除的文件类型
def GetFileList(dir, fileList):
newDir = dir
if os.path.isfile(dir):
if dir.endswith(suffix) :
fileList.append(dir)
os.remove(dir)
print "删除文件名:" + dir
elif os.path.isdir(dir):
for s in os.listdir(dir):
newDir=os.path.join(dir,s)
GetFileList(newDir, fileList)
return fileList
list = GetFileList(path, [])
print "已删除当前所有"+suffix+"文件:"
import time
path = "F:\\zjbg" #文件夹路径
suffix = ".html" #需要删除的文件类型
def GetFileList(dir, fileList):
newDir = dir
if os.path.isfile(dir):
if dir.endswith(suffix) :
fileList.append(dir)
os.remove(dir)
print "删除文件名:" + dir
elif os.path.isdir(dir):
for s in os.listdir(dir):
newDir=os.path.join(dir,s)
GetFileList(newDir, fileList)
return fileList
list = GetFileList(path, [])
print "已删除当前所有"+suffix+"文件:"