python basis of Ganso tuple

Ganso is a read-only list, not hash, can be recycled inquiries, sliced 
* son can not be changed, change the grandchildren - Ganso inside a single element can not be changed --- yuan in the list of ancestors can be changed
by: tu1 + tu2
check: tu1 [index ] tu1 [start_index: end_index] tu1.index (obj)
change: tu1 [index] [index] = list obj --tuple presence can change the
statistics: len (TU1) tu1.count (obj)
. 1, cycle:
EY :
tu1 = (1,2,'ee',3,[6,7,8,'ww'],4,'hh')
for tu in tu1:
    print(tu)
2, check, sliced: sliced still returns Ganso 
ey:
= tu1 (1,2, ' ee ' , 3, [678, ' ww ' ], 4, ' in hh ' ) 
tu2 = tu1 [2 ]
 the print (tu2)
Result: 'The 
dog:
= tu1 (1,2, ' ee ' , 3, [678, ' ww ' ], 4, ' in hh ' ) 
tu2 = tu1 [0: 2 ]
 the print (tu2)
Result: (1, 2, 'in') 
are:
= tu1 (1,2, ' ee ' , 3, [678, ' ww ' ], 4, ' in hh ' ) 
tu2 = tu1 [0: 5: 2 ]
 the print (tu2)
result:(1, 'ee', [6, 7, 8, 'ww'])
3,改
= TU1 (1,2, ' EE ' ,. 3, [6,7, 8, ' WW ' ],. 4, ' HH ' ) 
TU1 [ . 4] [2] = ' Gai ' 
Print (TU1)
Result: (. 1, 2, 'EE',. 3, [. 6,. 7, 'Gai', 'WW'],. 4, 'HH') 
. 4, by: adding
= tu1 (1,2, ' ee ' , 3, [678, ' ww ' ], 4, ' in hh ' ) 
tu2 = (1123 )
 the print (tu1 + tu2)
Result: (. 1, 2, 'EE',. 3, [. 6,. 7,. 8, 'WW'],. 4, 'HH',. 11, 23 is) 
. 5, calculated length
TU1 = (1,2,3,4 )
 print (referred to as (TU1))
the Result: 4 
6, statistics
tu1 = (1,2,'ee',3,[6,7,8,'ww'],4,'hh')
print(tu1.count('ee'))
the Result: 1 
7, the index
ey:
tu1 = (1.2, ' a ' , 3, [6,7,8, ' ww ' ], 4, ' hh ' )
 print (tu1.index ( ' hh ' ))
result:6

Guess you like

Origin www.cnblogs.com/meifei/p/11390113.html