ywh123456's recent timeline updates
ywh123456

ywh123456

V2EX member #322001, joined on 2018-06-11 22:20:23 +08:00
ywh123456's recent replies
Jun 12, 2018
Replied to a topic by webing Python Python 两个大列表如何对比相同内容并合并?
from collections import defaultdict
a = [
['11', 'wqdqwdwd', '允许撒大声地'],
['22', 'ewrdwewd', '允许打发斯蒂'],
['33', 'hghfgfgh', '允许撒大我地'],
['44', 'gfdgdgrg', '允许伟大无多']
]

b = [
['22', 'jhgfghfgh', '允许 dawdadd'],
['33', 'hfghgffgh', '允许 wadawwa'],
['44', 'jyjygjyyd', '允许 dwadwad'],
['11', 'ikluhkmug', '允许 dwadwad']
]

c = defaultdict(list)
for tmp in a + b:
c[tmp[0]].append(tmp)

#输出
for key in c.keys():
print("{} has {}".format(key,c[key]))
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5831 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 20ms · UTC 02:54 · PVG 10:54 · LAX 19:54 · JFK 22:54
♥ Do have faith in what you're doing.