python日记----2017.8.2

有待补充:

处理文件,用户指定要查找的文件和内容
将文件中包含要查找内容的每一行都输出到屏幕

def file(filename,find_l):
with open(filename,'r',encoding='utf-8') as read_r:
lines = read_r.readlines()
for k,v in enumerate(lines):
# print(k)
if not v.find(find_l) == -1:
yield k+1, v
# else:
# yield '文件中没有你想要查询的值',enumerate(lines)

F = file('asd','一')
for f in F:
print(f)
posted @ 2017-08-02 22:22  你好丶  阅读(80)  评论(0编辑  收藏  举报