查找文档内容

1
2
3
4
5
6
7
import  os
target = input("please input the search word:")
for filename in os.listdir("."):
if "." in filename:
with open (filename,'r',encoding='UTF-8') as f:
if target in f.read():
print(os.path.basename(filename))