import collections n=5 buffer=collections.deque(maxlen=n) buffer.append ( ' 5 ' ) # the end of the additional buffer.popleft () # left delete buffer.count ( ' 5 ' ) # statistics Print (len (Buffer)) # length IF ' . 5 ' in Buffer: # whether there is a value Print ( ' present ' )
Queue related operation