- くだすれPython(超初心者用) その26 [転載禁止]©2ch.net
487 :デフォルトの名無しさん[sage]:2015/07/22(水) 17:00:44.90 ID:Hp3Ht5RA - >>473
入力に間違いがない前提 import sys def getlog(pattern, inp=sys.stdin, out=sys.stdout): buf = [] for line in inp: if pattern in line or len(buf) > 0: buf.append(line) if len(buf) >= 6: break out.writelines(buf) with open('input.txt') as i, open('outout.txt', 'w') as o: getlog('pattern', i, o)
|