记录一个小知识点:
Python的filter函数,当第一个参数,即function,传入None时,是在干什么呢?
查了下文档,是这样解释的:
filter() Parameters
The filter() method takes two parameters:
- function - function that tests if elements of an iterable returns true or false
If None, the function defaults to Identity function - which returns false if any elements are false - iterable - iterable which is to be filtered, could be sets, lists, tuples, or containers of any iterator
一句话说,就是把序列中的False值,如空字符串、False、[]、None、{}、()等等都丢弃。:)