import os
def find_certain_files(keyword = input("search:") ):
result = []
for path,dirs,files in os.walk("文件夹"):
for file in files:
if file.endswith(".txt"):
fileWithPath = os.path.join(path,file)
a = open(fileWithPath)
b = a.read()
if keyword in b:
result.append(fileWithPath)
a.close()