Data:
The elements of the list are variable and are created with a [] or list ().
The elements of the Ganso are immutable, created with () or tuple ().
The elements of the collection are not repeatable and are created with the {} or set ().
The dictionary is stored k-v, created with dict () or {}.
Del: Delete data structure element or variable by index
===================================================
List
List.append (x) = = = A[len (a):]=[x]
List.extend (L) = = = A[len (a):]=l
List.insert (i,x) #指定位置插入
List.remove (x)
List.pop ([i])
List.index (x)
You can use the list as a stack
Implementing a queue using Collections.deque
1 from Import deque 2 queue = deque (["a","b","C "])3 queue.append ("D")4 Queue.popleft ()
View Code
===================================================
Functional Programming Tools: Filter (), map (), reduce ()
Filter (Bool_func, sequence) returns an sequence that includes all the elements in the given sequence that return a value of true after all calls to Bool_func (item). (The same type is returned, if possible). If the sequence (sequence) is a string (string) or a tuple (tuple), the return value must be the same type, otherwise it is always list. For example, the following programs can calculate partial primes:
1 def F (x):return and x%3!=02 filter (F,range (2,25))
Map (function, seq1,[seq2 ...]) invokes function (item) in turn for each element and returns the return value as a list. For example, the following program computes the cube:
1 def Cube (x):return x*x*x2 map (Cube,range (1,10))
1 seq = range (8)2def Add (x, y):return x+y3 Map (ADD,SEQ,SEQ)4#ans [0,2,4,6,8,10,12,14]
Reduce (function, sequence) returns a single value, which is constructed by invoking function functions first with the first two elements of the sequence, then invoking the return value and the third argument, and sequentially executing. For example, the following program calculates the sum of integers 1 to 10:
1 def Add (x, y):return x+y2 reduce (Add,range (1,11))
===================================================
Python QuickStart (3)