Deque two-way queue and deque queue
Import collections as condq = con. deque () # Add dq to the right. append (1) print (dq, 'append') # Add dq on the left. appendleft (2) print (dq, dq [0], 'appendleft') # Clear the queue # dq. clear () # print (dq. count (1), 'Count') # Extend the queue dq on the right. extend ([5, 6, 7]) print (dq, 'extend') # extend the queue dq on the left. extendleft ([0, 0, 0]) print (dq, 'extendleft') # obtain the index that appears for the first time. The last two Parameters specify the start and end positions, the print (dq. index (1), 'index') # Insert the element dq at the specified position. insert (1, [2, 2, 2]) print (dq, 'insert') # retrieve and delete the rightmost element print (dq. pop (), 'Pop ') # retrieve and delete the leftmost element print (dq. popleft (), 'popleft ') # output the specified value dq. remove ([2, 2, 2]) print (dq, 'delete') # reverse the order dq. reverse () print (dq, 'reverse') # Add the elements on the right to the left one time by quantity. rotate (3) print (dq, 'rotate') exit ()