This is in the official website list support, have realized.
To supplement the stack, the characteristics of the queue:
1. Stack (stacks) is a linear data structure that can only be accessed by accessing the first end of the database, and has the characteristics of the LIFO (last Out,lifo)
2. A queue is a linear data structure with FIFO features, where the addition of elements can only be done at one end, and the deletion of elements can only take place at the other end. The one end of the queue that can increment the element is called the tail of the queue, and the one end of the element is called the team head.
Address in http://docs.python.org/2/tutorial/datastructures.html#more-on-lists, below the official code.
About Stacks
>>>Stack=[3,4,5]>>>Stack.Append(6)>>>Stackappend (7) >>> stack[3, 4, 5, 6, 7]>>> stack pop () 7>>> stack[3, 4, 5, 6]>>> stack. Pop () 6>>> stack.< span class= "n" >pop () 5>>> stack[3, 4]
about the queue
>>>FromCollectionsImportDeque>>>Queue=Deque(["Eric","John","Michael"])>>>Queue.Append("Terry")# Terry arrives>>> queue. Append ( "Graham" ) # Graham arrives >>> queue. Popleft () # the first to arrive now Leaves ' Eric ' >>> queue. Popleft () # the second to arrive now Leaves ' John ' >>> queue # Remaining queue in order of Arrivaldeque ([' Michael ', ' Terry ', ' Graham '])
Python--python data structure stack, queue implementation