看板 Python 關於我們 聯絡資訊
target = {'a': [ab, cd, ef], 'b': [ac, cd, ef, gh], 'c': [bh, ef, cd, jk], ...} 假設target還有很多keys... 請問如何將 所有的 values of target取 set 以我舉的例子 我想得到 一個 set (cd, ef) 請教一下code該怎麼寫呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 192.203.57.28
AndCycle:set有個function叫intersection 02/20 16:23
AlanSung:s = map (lambda x: set(x), target.values()) 02/20 17:07
AlanSung:print reduce (lambda x, y: x.intersection(y), s) 02/20 17:07