假设我的清单如下:
list1 = [('do not care1', 'some string'),
('do not care1', 'some new string'),
('do not care2', 'some string'),
('do not care3', 'some other stringA')
('do not care4', 'some other stringA')
('do not care10', 'some other stringB')
('do not care54', 'some string')
只有当第二个值重复超过2次时,我才需要整个条目
在上面的示例中,我希望看到这样的输出
'do not care1', 'some string'
'do not care2', 'some string'
'do not care54', 'some string'
我该怎么做呢
您可以使用
collections.Counter
和列表理解:相关问题 更多 >
编程相关推荐