Python 魔法
多重循环嵌套?-4行代码实现管道
https://aber.sh/articles/Python-Pipe/
from functools import partial
class F(partial):
def __ror__(self, other):
return self(other)
# 求十以下所有奇数的和:
range(10) | F(filter, lambda x: x % 2) | F(sum)
# 筛选字典中值为真的数据:
{1:True,2:False} | F(lambda d: {k: v for k, v in d.items() if v})