python3-cookbook icon indicating copy to clipboard operation
python3-cookbook copied to clipboard

你好,1.3节例子代码有问题

Open ldonlytest opened this issue 7 years ago • 4 comments

源码: def search(lines, pattern, history=5): previous_lines = deque(maxlen=history) for li in lines: if pattern in li: yield li, previous_lines previous_lines.append(li)

ldonlytest avatar Aug 30 '17 06:08 ldonlytest

确实有问题,文件的最后一行会被忽略

mengxunQAQ avatar Jan 26 '18 03:01 mengxunQAQ

最后一行缩进错误吧, if判断无用

vinsonw avatar Feb 11 '18 12:02 vinsonw

问题已找到!把for pattern_result in search(f, 'python', history=5):这一行的python改成Python

leoKking avatar Aug 23 '19 04:08 leoKking