A, defined tuple
Tuple Once established, within tuple element can not be edited and deleted, which is a list of tuples and the biggest difference
When only one tuple element, after the element needs to be a comma, or may be no brackets.
1 tuple1 = (12,3234,54354,656,6) 2 tuple2 = (12,) 3 tuple3 = 12, 4 tuple2 == tuple3 5 True
Second, access tuple
Tuple name [index] tuple access the same forms and lists
NOTE: may be used for tuples splicing operator "+" repetition operator "*", logical operators, relational operators, and members of the operator, can be sliced tuple, can be used del deleted tuples, but you can not delete an element
Third, you can employ special methods delete and modify tuple element (splice element group and the fragment generated tuple name to the name of the original tuple)
. 1 tuple1 = ( ' James ' , ' Davies ' , ' George ' , ' Westbrook ' ) 2 tuple1 tuple1 = [:. 1] + ( ' Lillard ' ,) + tuple1 [2 :] . 3 tuple1 . 4 ( ' James ' , ' Lillard ' , ' George ' , ' Westbrook ' )
The original tuple still exists, but is not called tuple1, and soon it will be garbage collection mechanism