python编程快速上手之第8章实践项目参考答案(8.9.3)
import os,sys,re
# 打开文件
key = input('Enter the key word:\n')
path = "C:\\Users\\Administrator\\Python35-32\\test"#替换为自己的文件路径
for f in os.listdir(path):
if f.endswith('.txt'):
for file in open(f):
if key in file:
print(file)
posted on 2017-04-13 00:36 flying-wyf 阅读(148) 评论(2) 编辑 收藏 举报