maddevil 最近的时间轴更新
maddevil

maddevil

V2EX 第 458521 号会员,加入于 2019-12-10 18:21:59 +08:00
今日活跃度排名 17930
maddevil 最近回复了
2021-01-11 19:24:49 +08:00
回复了 abersheeran 创建的主题 Python 六行代码实现 Python 管道
from functools import partial

F = type("F", (partial,), {"__ror__": lambda self, other: self(other)})
range(10) | F(filter, lambda x: x & 1) | F(sum) | F(print)
其实还可以一行搞定:
{k: [j for i in v for j in i.keys()] for k, v in mylist.items()}
```
mylist = {"key": [{'a': '1'}, {'b': '2'}]}
all = {}
for k, v in mylist.items():
all[k] = []
for j in v:
all[k] += j.keys()
```
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   946 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 22:49 · PVG 06:49 · LAX 14:49 · JFK 17:49
Developed with CodeLauncher
♥ Do have faith in what you're doing.