文件脱敏
1import os, re 2 3def isTarget(file, pattern): 4 f = open(file, 'r') 5 result = False 6 for line in f: 7 if (re.match(pattern, line, flags=0)): 8 result = True 9 break 10 return result 11 12def getFileList(root_path): 13 list_f = [] 14 for root, dirs, files in os.walk(root_path): 15 for file in files: 16 list_f.append(os.path.join(root, file)) 17 return list_f 18 19if __name__ == "__main__": 20 print(getFileList('/home/ydx/Documents/Project/Python-Practice')) 21#'/home/ydx/Documents/Project/Python-Practice/rabbit.txt'