时间:2021-07-01 10:21:17 帮助过:74人阅读
代码如下:
代码如下:
import os
import os.path
def DeleteFiles(path,fileList):
for parent,dirnames,filenames in os.walk(path):
FullPathList = []
DestPathList = []
for x in fileList:
DestPath = path + x
DestPathList.append(DestPath)
for filename in filenames:
FullPath = os.path.join(parent,filename)
FullPathList.append(FullPath)
for xlist in FullPathList:
if xlist not in DestPathList:
os.remove(xlist)
代码如下:
for x in fileList:
DestPath = path + x
DestPathList.append(DestPath)
代码如下:
for filename in filenames:
FullPath = os.path.join(parent,filename)
FullPathList.append(FullPath)
代码如下:
for xlist in FullPathList:
if xlist not in DestPathList:
os.remove(xlist)