python container -list

#list

List name .append (element) element added to the end of
the list .insert (index, element) insert elements

List name = list (iterable) traversal iterables join list


= A [l, 2,3]
B = [ 'A', 'V']
A + B =
Print (A) [. 1, 2,. 3, 'A', 'V']
L.extend (LST) | to list append another list the same effect

 

List name [index] = element
variable name = list [index]
variable name = list [slice] # assigned to the variable is a list of new sections created
list name [slice] # = the right side of the container must be iterables, left side sections did not create a new list. Traverse the container, turn into

 

List name .remove (element)
del list name [index or slice]

Function:
Find
L.index (v [, begin [, end]]) | returns the corresponding element of the index index, begin to start index, end to end of the index, triggering ValueError error when value is not present
L.count (x) | statistics for an element that appears in the list of the number of
L.pop ([index]) | delete the index corresponding element, if not indexed by default to remove the last element, and returns a reference to the relationship between removing elements


modify

L.clear () | clear the list is equivalent to L [:] = []
L.sort (Reverse = False) | elements in the sorted list, the default value of the order of small to large order
L.reverse ( ) | reversal of the list, to change the original list order
copies
L.copy () | copy of this list (only one copy will not copy deep objects)

 

Deriving a list of the formula
l = [i for i in range (10)]

Guess you like

Origin www.cnblogs.com/chenlulu1122/p/11921756.html