首页 > 代码库 > 关于map()与filter()

关于map()与filter()

def f1(a):
    if a == 3:
        pass
    else:
        return a*a
li = [1,2,3,4]
for i in f
技术分享
1,li):
    print(i)
def f1(a):
    if a == 3:
        pass
    else:
        return a*a
li = [1,2,3,4]
# for i in filter(f1,li):
#     print(i)

for i in map(f1,li):
    print(i)

技术分享

关于map()与filter()