利用python deque的extend特性实现列表元素查重

from collections import deque

mydquene = deque()

mylist = [0,1,1,2,2,3,3,3,3,4,5,6,7,7,8,8,9,10,10,11,22,33,22]

mydquene.extend(mylist)

for i in set(mylist):

     n = mydquene.count(i)

     if n>1:

         print("其中元素{}出现了{}次\r\n".format(i,n))
上一篇:Python 列表元素分组,比如 [1,2,3,...20]变成 [[1,2,3],[4,5,6]....](列表生成式解决)


下一篇:Azure School 终于上线了,物联网开发课程先走一波~