Skip to content

Commit a43f703

Browse files
authored
Merge pull request yidao620c#128 from caimaoy/fix-python-code
Add ',', modify output result
2 parents 35a4fa6 + ab1bbb5 commit a43f703

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cookbook/c01/p16_filter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- encoding: utf-8 -*-
33
"""
44
Topic: 序列元素过滤
5-
Desc :
5+
Desc :
66
"""
77
from itertools import compress
88

@@ -37,7 +37,7 @@ def is_int(val):
3737
'5412 N CLARK',
3838
'5148 N CLARK',
3939
'5800 E 58TH',
40-
'2122 N CLARK'
40+
'2122 N CLARK',
4141
'5645 N RAVENSWOOD',
4242
'1060 W ADDISON',
4343
'4801 N BROADWAY',
@@ -49,4 +49,4 @@ def is_int(val):
4949

5050

5151
if __name__ == '__main__':
52-
cb_filter()
52+
cb_filter()

source/c01/p16_filter_sequence_elements.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
'5412 N CLARK',
9595
'5148 N CLARK',
9696
'5800 E 58TH',
97-
'2122 N CLARK'
97+
'2122 N CLARK',
9898
'5645 N RAVENSWOOD',
9999
'1060 W ADDISON',
100100
'4801 N BROADWAY',
@@ -111,7 +111,7 @@
111111
>>> more5
112112
[False, False, True, False, False, True, True, False]
113113
>>> list(compress(addresses, more5))
114-
['5800 E 58TH', '4801 N BROADWAY', '1039 W GRANVILLE']
114+
['5800 E 58TH', '1060 W ADDISON', '4801 N BROADWAY']
115115
>>>
116116
这里的关键点在于先创建一个 ``Boolean`` 序列,指示哪些元素符合条件。
117117
然后 ``compress()`` 函数根据这个序列去选择输出对应位置为 ``True`` 的元素。

0 commit comments

Comments
 (0)