我有一个元组列表(如下所示),我需要在每个元组的第一个项上加入这些元组。因此,结果将是(word,list(numbers))元组的列表。在
In [351]: word_docid_pairs
Out[351]:
[('bear', 1),
('is', 1),
('in', 1),
('gugledarc', 1),
('the', 1),
('sdpij', 2),
('emdf', 2),
('sai', 2),
('sd', 3),
('fuggle', 4),
('in', 4),
('gugledarc', 4),
('df', 4)]
如前所述,下面是另一个使用
^{pr2}$defaultdict
的实现:相关问题 更多 >
编程相关推荐