找出list中的重复元素

a = [1,2,3,2,1,5,6,5,5,5]

import collections
print([item for item, count in collections.Counter(a).items() if count > 1])

输出

[1, 2, 5]

Pycharm warning:
This inspection reports discrepancies between declared parameters and actual arguments, as well as incorrect arguments and incorrect argument order.

猜你喜欢

转载自blog.csdn.net/tcx1992/article/details/80334080