Python 使用filter()去除list的空值
d =['','剧情','喜剧','恐怖','','伦理',''] d_dropna = list(filter(None, d)) #去除列表空值,非常简单好用 ''' 注意: 空字符串 会被程序判定为 False filter(None, your_list), None代表不输入函数,也就是 [x for x in your_list if x] '''
filter的使用参考:
https://docs.python.org/3/library/functions.html#filter
参考链接:
标签:空值,None,Python,list,filter,去除 From: https://www.cnblogs.com/2018shawn/p/16991399.html