我想从第 1 列中删除重复项,并在第 2 列中返回与使用 python 的每个唯一项关联的值的相关列表。
输入是
1 2
Jack London 'Son of the Wolf'
Jack London 'Chris Farrington'
Jack London 'The God of His Fathers'
Jack London 'Children of the Frost'
William Shakespeare 'Venus and Adonis'
William Shakespeare 'The Rape of Lucrece'
Oscar Wilde 'Ravenna'
Oscar Wilde 'Poems'
而输出应该是
1 2
Jack London 'Son of the Wolf, Chris Farrington, Able Seaman, The God of His Fathers,Children of the Frost'
William Shakespeare 'The Rape of Lucrece,Venus and Adonis'
Oscar Wilde 'Ravenna,Poems'
其中第二列包含与每个项目关联的值的总和。我在字典上尝试了 set() 函数
dic={'Jack London': 'Son of the Wolf', 'Jack London': 'Chris Farrington', 'Jack London': 'The God of His Fathers'}
set(dic)
但它只返回字典的第一个键
set(['Jack London'])