第二步,文件搜索关键字 Mark
_ignoreList = [".png",".plist",".pch",""] #忽略名单 ,"" = 隐藏文件
def Search_keyword(path, keyWord):
for root, dirs, files in os.walk(path):
for name in files:
if os.path.splitext(name)[-1] not in _ignoreList: #忽略扩展名
fp = os.path.join(root, name)
with open(fp,'r') as f:
i = 1
for line in f:
if keyWord in line:
print('%s 第%d行' % (fp,i))
i +=1