Skip to content

Update Filter.md #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Map & Filter/Filter.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ```Filter```

顾名思义,```filter```能创建一个列表,其中每个元素都是对一个函数能返回```True```. 这里是一个简短的例子:
顾名思义,```filter```过滤列表中的元素,并且返回一个由所有符合要求的元素所构成的列表,```符合要求```即函数映射到该元素时返回值为True. 这里是一个简短的例子:
```python
number_list = range(-5, 5)
less_than_zero = list(filter(lambda x: x < 0, number_list))
less_than_zero = filter(lambda x: x < 0, number_list)
print(less_than_zero)

# Output: [-5, -4, -3, -2, -1]
Expand Down