filter 函数 过滤函数

# 去掉空白的字符
def not_empty(s):
    return s and s.strip()

l=list(filter(not_empty, ['A', '', 'B', None, 'C', '  ']))

print(l)
'''
['A', 'B', 'C']
'''

 

posted @ 2023-07-08 21:39  胖豆芽  阅读(6)  评论(0编辑  收藏  举报