Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 371 Bytes

72.md

File metadata and controls

23 lines (16 loc) · 371 Bytes
@author jackzhenguo
@desc 
@date 2019/4/15

72 按条件分组

def bif_by(lst, f):
    return [ [x for x in lst if f(x)],[x for x in lst if not f(x)]]

测试举例:

records = [25,89,31,34] 
bif_by(records, lambda x: x<80) # [[25, 31, 34], [89]]
[上一个例子](71.md) [下一个例子](73.md)