看板 Python 關於我們 聯絡資訊
想請問一下 如果我有像下列的tuple (to, you), (to, me), (to, him), (to, us) 等等 要怎麼樣把這些tuple轉成像下面的dictionary {to: ['you', 'me', 'him', 'us']} 我試過用 d = {} for item in tuple: if item[0] in d: d[item[0]] += item[1] 但是行不通 先謝過大家了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 69.143.181.102