The implementation of a language class library or data structure is particularly important for this language. Currently, unless it is very low-level, development efficiency is generally required, such as the Java JDK, he comes with a lot of useful classes, and the C ++ STL is also a very useful template library. Python is not an example. Here we introduce the implementation of two simple data structures, namely, sequences and dictionaries. In fact, it is very simple to hear this name. This sequence is actually a List interface in Java or a simple linked List. It may be an array implementation or pointer implementation, but the basic function is to Add data and Get data, then we can randomly access data based on the Index, which is basically a container for storing data or objects. It is called a sequence in Python. The dictionary is actually a key-value pair, which is equivalent to Map. More specifically, it is equivalent to LinkedHashMap in Java, this is because the dictionary does not disrupt the Hash Storage during traversal, but stores the original sequence in the form of a linked list. The following describes the sequence and dictionary examples. [Python] ''' Created on @ author: Administrator ''' shoplist = ['apple', 'Banana ', 'orange ', 'peach '] print ("I need to buy", len (shoplist), "seed fruit") print ("these fruits are") for I in shoplist: print (I) print ("I still have to buy") shoplist. append ("watermelon") print ("the current list is", shoplist) print ("I need to sort") shoplist. sort (key = None, reverse = False) print ("the sorted list is", shoplist) print ("the first product I want to buy is", shoplist [0]) del shoplist [0] print ("the current list after deletion is", shoplist) ''' Create D on @ author: Administrator ''' shoplist = ['apple', 'Banana ', 'orange', 'peach'] print ("I need to buy ", len (shoplist), "Fruit") print ("these fruits are") for I in shoplist: print (I) print ("I still have to buy") shoplist. append ("watermelon") print ("the current list is", shoplist) print ("I need to sort") shoplist. sort (key = None, reverse = False) print ("the sorted list is", shoplist) print ("the first product I want to buy is", shoplist [0]) del shoplist [0] print ("the current list after deletion is", shoplist) This example can easily explain the sequence. The basic CRUD is complete. Next let's talk about the dictionary [python] ''' Created on 2013-1-23 @ author: Administrator ''' mymap = {'A': 'hahaha', 'B ': 'bb', 'C': 'cc'} print (mymap ['a']) print ("length is", len (mymap) for name, address in mymap. items (): print (name, "=", address) mymap ['D'] = 'dd' for name, address in mymap. items (): print (name, "=", address) del mymap ['a'] for name, address in mymap. items (): print (name, "=", address) ''' Created on 2013-1-23 @ author: Administrator ''' mymap = {'A': 'haha ', 'B': 'bb', 'C': 'cc'} print (mymap ['a']) print ("length is", len (mymap) for name, address in mymap. items (): print (name, "=", address) mymap ['D'] = 'dd' for name, address in mymap. items (): print (name, "=", address) del mymap ['a'] for name, address in mymap. the items (): print (name, "=", address) dictionary is actually Map. CRUD is basically easy.