maddevil 最近的时间轴更新
maddevil

maddevil

V2EX 第 458521 号会员,加入于 2019-12-10 18:21:59 +08:00
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   ·   实用小工具   ·   2663 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 12:15 · PVG 20:15 · LAX 05:15 · JFK 08:15
Developed with CodeLauncher
♥ Do have faith in what you're doing.