An immutable sequence of tuple tuples. Contains arbitrary objects. can be nested arbitrarily. Accessed through the following table. No support for in-situ changes
Immutable refers to not supporting in-situ changes, nor appending elements and extension elements like lists
Syntax: t = () parentheses represent tuples
Problem:
If we write T = (' Mike ') directly. This will be treated as a string, and you want to declare that the tuple needs to write T = ("Mike")
When assigning tuples, parentheses can be omitted.
The tuple () function converts an iterative sequence into a tuple
Access to tuples is consistent with list access
Some other actions: (The following operation produces a new object)
The common operation of tuples is consistent with the general operation of the list, such as:
T in Tuple1 an element inside a tuple
T in Tuple1 an element is not inside a tuple
Tuple1 + tuple2
Tuple1 * 2
Tuple[index]
tuple[I:j]
tuple[i:j: K]
Len (tuple) tuple length
MIN (tuple) Minimum value
Max (tuple) maximum value
SUM (tuple) Total
Tuple.index (x) The first occurrence of an element in a tuple subscript
Tuple.count (x) an element appears several times
Extended:
A, B = 5, 10 This is the assignment of 2 variables respectively. Instead of declaring a tuple
The value of the interchange A and B can be so sub-written A, B = B, a
Python 0 Basic Primer (8)-------tuple tuples