Tuple tuple

Copy the code

# Why have tuples, storing a plurality of values, immutable tuples, is used to make queries more 
T = (. 1, [l, 3], ' sss ' , (1,2)) # T = tuple ((. 1, [l, 3], 'sss', (1,2))) 
# Print (type (T)) 


# # tuples as dictionary Key 
# D = {(l, 2,3): 'Egon'} 
# Print (D, type (D), D [(l, 2,3)]) 

 


#      slice 
# Goods = ( 'iPhone', 'Lenovo', 'Sanxing', 'suoyi') 
# Print ( Goods [. 1:. 3]) 



#      length 

# in: 
# string: substring 
# listing: element 
# tuple: element 
# dictionary: Key 

# Goods = ( 'iPhone', 'Lenovo', 'Sanxing', 'suoyi ')
#print ( 'iphone' in goods) to see the inside of the element is not inside 

# D = { 'A':. 1, 'B': 2, 'C':. 3} 
# Print ( 'B' in D) see d is not inside the key 

 

# master 
# Goods = ( 'iPhone', 'Lenovo', 'Sanxing', 'suoyi') 
# Print (goods.index ( 'iPhone')) 
# Print (goods.count ( 'iPhone' )) 


# NOTE: tuple itself is not changed, but the interior of the elements may be variable type 
T = (. 1, [ ' a ' , ' B ' ], ' sss ' , (1,2)) # T = tuple ((. 1, [l, 3], 'sss', (1,2))) 

# T [. 1] [0] = 'A'
# print(t)
# t[1]='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
Copy the code

 

Copy the code

# Why have tuples, storing a plurality of values, immutable tuples, is used to make queries more 
T = (. 1, [l, 3], ' sss ' , (1,2)) # T = tuple ((. 1, [l, 3], 'sss', (1,2))) 
# Print (type (T)) 


# # tuples as dictionary Key 
# D = {(l, 2,3): 'Egon'} 
# Print (D, type (D), D [(l, 2,3)]) 

 


#      slice 
# Goods = ( 'iPhone', 'Lenovo', 'Sanxing', 'suoyi') 
# Print ( Goods [. 1:. 3]) 



#      length 

# in: 
# string: substring 
# listing: element 
# tuple: element 
# dictionary: Key 

# Goods = ( 'iPhone', 'Lenovo', 'Sanxing', 'suoyi ')
#print ( 'iphone' in goods) to see the inside of the element is not inside 

# D = { 'A':. 1, 'B': 2, 'C':. 3} 
# Print ( 'B' in D) see d is not inside the key 

 

# master 
# Goods = ( 'iPhone', 'Lenovo', 'Sanxing', 'suoyi') 
# Print (goods.index ( 'iPhone')) 
# Print (goods.count ( 'iPhone' )) 


# NOTE: tuple itself is not changed, but the interior of the elements may be variable type 
T = (. 1, [ ' a ' , ' B ' ], ' sss ' , (1,2)) # T = tuple ((. 1, [l, 3], 'sss', (1,2))) 

# T [. 1] [0] = 'A'
# print(t)
# t[1]='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
Copy the code

 

Guess you like

Origin www.cnblogs.com/maaosheng/p/11619104.html