"""用户需要查询文件,针对文件内容进行筛选,并且输出"""def lin(filename,aim): with open(filename,encoding='utf-8') as f: for i in f: if aim in i: yield ig=lin('正则.py','装饰器')for l in g: print(l.strip())