Skip to content

Commit 092eaf6

Browse files
authored
dropwhile() 示例代码错误
第一次示例 LIne 44,应该是: ... for line in dropwhile(lambda line: line.startswith('#'), f): 而不是: ... for line in dropwhile(lambda line: not line.startswith('#'), f): 因为这里的目的是不显示 # 开头的文本
1 parent 913ea87 commit 092eaf6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/c04/p08_skip_first_part_of_iterable.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
>>> from itertools import dropwhile
4343
>>> with open('/etc/passwd') as f:
44-
... for line in dropwhile(lambda line: not line.startswith('#'), f):
44+
... for line in dropwhile(lambda line: line.startswith('#'), f):
4545
... print(line, end='')
4646
...
4747
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false

0 commit comments

Comments
 (0)