我想逐行读取大文本文件(如果找到带有"str"的行,则停止).如果到达文件结尾怎么检查?
fn = 't.log' f = open(fn, 'r') while not _is_eof(f): ## how to check that end is reached? s = f.readline() print s if "str" in s: break
python file
file ×1
python ×1