写爬虫无意中发现的(原代码比较复杂,下面这是我模仿其结构写的)
可为什么不会报错???? 空列表直接过滤掉了,那这样写可以直接过滤空值啦?岂不是非常爽?还是我小白了,这里面有我不知道的原理?
def die(l): for d in l: count = d[0]+d[1] yield count
s = [ [['A','B']],[],
[['C','D']],[]
]
for i in s: for j in die(i): print('++',j)
输出 :++ AB ++ CD