标签:枚举 lse obj png oop span mamicode 类型 object
def bifurcate(lst, filter): print(lst) # [‘beep‘, ‘boop‘, ‘foo‘, ‘bar‘] print(filter) # [True, True, False, True] # 列表名,不是 filter 函数 print(enumerate(lst)) # <enumerate object at 0x0000017EB10B9D00> print(list(enumerate(lst))) # [(0, ‘beep‘), (1, ‘boop‘), (2, ‘foo‘), (3, ‘bar‘)] print([ [x for i, x in enumerate(lst) if filter[i] == True], [x for i, x in enumerate(lst) if filter[i] == False] ]) ‘‘‘ filter[i] 主要是对枚举类型前面的索引和传入的 filter 列表进行判断是否重复 ‘‘‘ bifurcate([‘beep‘, ‘boop‘, ‘foo‘, ‘bar‘], [True, True, False, True])
标签:枚举 lse obj png oop span mamicode 类型 object
原文地址:https://www.cnblogs.com/hany-postq473111315/p/12821665.html