文件脱敏
import os, re
def isTarget(file, pattern):
f = open(file, 'r')
result = False
for line in f:
if (re.match(pattern, line, flags=0)):
result = True
break
return result
def getFileList(root_path):
list_f = []
for root, dirs, files in os.walk(root_path):
for file in files:
list_f.append(os.path.join(root, file))
return list_f
if __name__ == "__main__":
print(getFileList('/home/ydx/Documents/Project/Python-Practice'))
#'/home/ydx/Documents/Project/Python-Practice/rabbit.txt'