Python data structure

Source: Internet
Author: User
Tags python list

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.