#Meta-group[Ordered invariant sequence](Cannot be modified)
DefTuples ():
# ---Meta-group---
#Create(A list-like way to store data,But cannot be modified)
Tuples = ("Spokesperson",21st,"Woman")
tuples =Tuple ([A,"B","C"])#Converting a list to a tuple(Note:Converting a dictionary to a tuple can lose data)
tuples =Tuple ()#Empty tuple,Don't know what to do with
#xAdd toXModifyXDelete(Attention:Don't change it.)
#Get
Tuples = ("Spokesperson",21st,"Woman")
STRs = tuples[0]#Gets the specified index data, ‘Spokesperson‘
STRs = tuples[-1]#Countdown to get Data(1Begin), ‘Woman‘
TUP4 = tuples[1:]#Intercept, <class ' tuple ';: (21, 'Woman‘)
TUP5 = tuples[0:2]# <class ' tuple ';: ('Spokesperson', 21)
tup2 = tuples + (1,2,3)#Merging tuples(Primitive tuple unchanged), <class ' tuple ';: ('Spokesperson', 21, 'Woman', 1, 2, 3)
TUP3 = tuples *3#Copy(3Report)Merging tuples, <class ' tuple ';: ('Spokesperson', 21, 'Woman‘, ‘Spokesperson', 21, 'Woman‘, ‘Spokesperson', 21, 'Woman‘)
STRs =Max (1,3,6,2.5))# max , 6
STRs = min ((1 36 2.5))
# statistics
length = len (tuples) # count = Tuples.count (21) # The number of elements
#Find
index = Tuples.index (21)#The index at which the element appears,I can't find a throw exception.
index = Tuples.index (21st,1)#From1-End
index = Tuples.index (210 2) # from 0-2
# Span style= "COLOR: #808080" > traverse
for i in tuples:
Span style= "COLOR: #8888c6" >print ( "tuple:%s"%i)
# Judge
boolean = 21 in tuples
boolean = 21 not in tuples
python3-note-b-003-data structure-tuple tuple ()