dropwhile() 示例代码错误
第一次示例 LIne 44,应该是:
... for line in dropwhile(lambda line: line.startswith('#'), f):
而不是:
... for line in dropwhile(lambda line: not line.startswith('#'), f):
因为这里的目的是不显示 # 开头的文本
This commit is contained in:
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
>>> from itertools import dropwhile
|
>>> from itertools import dropwhile
|
||||||
>>> with open('/etc/passwd') as f:
|
>>> with open('/etc/passwd') as f:
|
||||||
... for line in dropwhile(lambda line: not line.startswith('#'), f):
|
... for line in dropwhile(lambda line: line.startswith('#'), f):
|
||||||
... print(line, end='')
|
... print(line, end='')
|
||||||
...
|
...
|
||||||
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
|
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
|
||||||
|
|||||||
Reference in New Issue
Block a user