python day 14 data type compositions - sequence (tuples and lists)

A combination of the data kind - sequence
a sequence
1. Sequence is a set of elements has a relationship with
2. Sequence is the one-dimensional vector elements, may be different types of elements
3. Similarly, the number of columns
4. Data type is a base class
5. Comprising
(1) Type String
(2) a list of type
(3) tuples
6. Reference: two types: incremental forward, reverse descending
Second, the basic sequence processing method
1. Six operators:
(. 1) in X-S
(2) Not in X-S
(. 3) + T S
(. 4) n-S *
(. 5) S []
(. 6) S [::]
2.5 or functions method
(1) Len () returns the length
(2) Min (s) returns the minimum element, provided that: all the elements in the set data size may be compared
(3) Max (s) returns the largest element
(4) S.index ( x, (i, j)) to find x (from the position of the first occurrence of i, to, J)
(. 5) S.count (X)
three tuple type
1. Features: tuple once created, can not be modified
2. Create: Use () or tuple () or no ()
3. def return a, b return the tuples
4. Scenario: data protection
Fourth, the type of list
1. After you create can be modified
2. Create: [] or List ()
3. Special Operation:
(. 1) Ls of [I] = X: assignment
(2) Ls [i: j : k] = lt: slice assignment
(3) Del ls [i] : Delete
(4) Del ls [i: j : k]: delete sections
(5) Ls.insert (i, x ): i x is inserted at
(6) Ls.pop (i): extraction element location i
(7) Ls .remove (x) : remove only the first X
(. 8) Ls.revers (): reverse list
(9) Ls.sort (): in ascending order
(10) Ls.sort (reverse = True ): descending order

Guess you like

Origin www.cnblogs.com/cfqlovem-521/p/12109931.html