python tuple (tuple) & dictionary (dict)

Tuple

1. tuple defines :
    tuples (tuple) is one of the Python standard data types, it is very similar to the list.

    Python is similar to a list of tuples, except that the elements of the tuple can not be modified. Tuples use parentheses, square brackets list. Tuple create very simple, only need to add elements in parentheses and
separated by commas can be. Tuple contains only one element, the element needs to be added after the comma.

2. Access tuple
    tuple subscripts may be used to access the index value tuple.

3. Modify the tuple
    element values tuple can not be modified, but it may be connected to a combination of tuples.

4. Remove the tuple
    element values in the tuple can not be deleted, but you can use the del statement to delete an entire tuple.

The operator tuple
    string as + and * can be used for operation between the number of tuples. This means that they can be combined and after replication operation will generate a new tuple.

6. The built-in functions tuple

function Explanation
cmp(tuple1, tuple2) Compare two tuple elements.
len (tuple) Count the number of tuples of elements.
max(tuple) Returns the maximum tuple element.
min(tuple) Returns the minimum element tuple.
tuple(seq) Convert list is a tuple.

Tuple operations :

Guess you like

Origin blog.csdn.net/qq_41490561/article/details/102881462