Python concept and basic operation tuple

Tuple list-like, on the same tuple you need to do the following three points:

A. Concepts

1. tuples constituting the parentheses in the English state "()". Which is stored as a list of elements, can be a number of barrier type, a barrier may be a data structure.

2. still a tuple sequences, several ways to obtain a list of the index element method can be used tuple object.

3. The biggest difference list is no longer a tuple of variable types of data structures

B. Since tuples only immutable data stored in a container, so that only two available "method", respectively, and the count index.

E.g:

t=('a','b','z','a','d','c','a')

The number of print (t.count ( 'a') # recording of 'a'

Positions print (t.index ( 'c')) # record 'c' of

 

Guess you like

Origin www.cnblogs.com/tinglele527/p/11683563.html