python 队列简单操作

import collections
n=5
buffer=collections.deque(maxlen=n)

buffer.append('5')#尾端追加
buffer.popleft()#左端删除
buffer.count('5')#统计

print(len(buffer))#长度
if '5' in buffer:#是否存在某个值
    print('存在')

队列有关操作

posted @ 2019-12-28 16:36  重积德  阅读(322)  评论(0编辑  收藏  举报