1 #python List2 3 #reverse Reverse Order4 #remove Delete the specified5 #clear Remove All6 #index The first subscript of the element7 #count The number of occurrences of this element8 #pop Delete the specified element and return it9 #insert inserting an element at a specified positionTen #append Add an element to the end of the list One #sort arranged from small to large A - - #堆栈 features (advanced out, LIFO) the #队列 features (FIFO, LIFO) -#队列缺点 =Each element is removed by one or more elements , and the other element positions are moved one by one, so the operation is much slower - - #堆栈操作 +stack = [3,4,5] -Stack.append (6) +Stack.append (7) A at print (Stack) - print (Stack.pop ()) - print (Stack.pop ()) - print (Stack) - - in #队列操作 - fromCollections Import Deque to +Queue = Deque (["Eric","John","Michael"]) -Queue.append ("Terry") theQueue.append ("Graham") * $ print (queue)Panax Notoginseng print (Queue.popleft ()) - print (Queue.popleft ()) thePrint (queue)
Python data structure