Python3 Tuple Operation Method

#list
lst = ['123','456','789','asd','asd']

#Convert a list to tuple.
tup = tuple(lst)

#tuple
tup = ('123','456','789','asd','asd')

#Gei the number of 'asd' in the tuple.
tup.count('asd')

#Get the index of  the first 'asd' in the tuple,begin 2 to the end.
tup.index('asd',2,-1)

#Calculate the number of elements of a tuple.
len(tup)

#Get element maximum in a tuple.
max(tup)

#Get element minimum  in a tuple.
min(tup)

猜你喜欢

转载自blog.csdn.net/qq_35351282/article/details/80723837