Why should there be tuples, () can hold multiple value tuples cannot be changed more is used to query
T = (1,[1,3], ' SSS ', (UP)) #t = tuple (1,[1,3], ' SSS ', ())
Print (Type (t))
Tuples can be a key to a dictionary
d={(+): ' Zcx '}
Print (D,type (d), d[())
Index values
D = (1,2,3,4,5)
Print (d[1])
Slice
Goods = (' iphone ', ' lenove ', ' Sum ', ' vivo ')
Print (Goods[1:3])
Print ((goods))
Length
Goods = (' iphone ', ' lenove ', ' Sum ', ' vivo ')
Print (len (goods))
Contains
Goods = (' iphone ', ' lenove ', ' Sum ', ' vivo ')
Print (' iphone ' in goods)
Master
Index, Count
Goods = (' iphone ', ' lenove ', ' Sum ', ' vivo ')
Print (Goods.index (' Lenove ')) #查询索引位置
Print (Goods.count (' Lenove ')) #计数
Add: The tuple itself is immutable, but the inner child element can be changed.
t= (1,[' A ', ' B '], ' SSS ', (UP))
t = ([1],[0], ' A ')
Print (Type (t))
Do not rely on indexed values
msg_dic={
' ASD ': 1111,
' Qwe ': 1222,
' Zxc ': 33333
}
For item in Msg_dic:
Print (Item,msg_dic)
msg= ' Hello '
# msg = [+]
msg = (all in all)
For item in MSG:
Print (item)
For: Supplemental
Len () takes the index print after the value
Range: Gu Tou regardless of tail default starting from 0
For I in Range (1,10,2):
Print (i)
For I in Range (10,1,-1):
Print (i)
Python = = "tuples