#!/user/bin/env pyhon3
# -*- coding:utf-8 -*-
import os,platform
class RemoveTagFile(object):
path=None
def removeFile(self,path,remove_list,retain_list):#path后面要跟/
self.path=path
system_test=platform.system()
if(system_test=='Windows'):
path_last=self.path[-1]
if(path_last!='\\' ):
self.path=self.path+'\\'
elif(system_test=='Linux'):
path_last =self.path[-1]
if (path_last !='/'):
self.path =self.path +'/'
if(len(remove_list)==0 and len(retain_list)==0):#如果remove_list,retain_list都是空则删除path目录下所有文件及文件夹
self.remove_file(self.eachFile(self.path))
elif(len(remove_list)>0 and len(retain_list)==0):
self.remove_file(remove_list)
elif(len(remove_list)==0 and len(retain_list)>0):
list=self.eachFile(self.path)
for fin retain_list:
if(fin list):
list.remove(f)
else:
print('There is no file in the directory!')
self.remove_file(list)
elif (len(remove_list) >0 and len(retain_list) >0):
for fin retain_list:
if(fi