DefTestenumerate ():
# Enumerate (iterable, start=0)
# EnumerateWillIterableMake up an index sequence that can be used to get both the index and the value
#More used inForGet counted in the loop
L = [A,' B ',' C ']# <class ' list ';: [' A ', ' B ', ' C ']
L1 =ListEnumerate (L))# <class ' list ': [(0, ' a '), (1, ' B '), (2, ' C ')]
T = (‘Happy‘,‘Happy‘,‘Happy‘)# <class ' tuple ';: ('Happy‘, ‘Happy‘, ‘Happy‘)
L1 =ListEnumerate (t))# <class ' list ';: [(0, 'Happy'), (1, 'Happy'), (2, 'Happy‘)]
D = {‘Shenzhen‘:1,‘Guangzhou‘:2,‘Zhuhai‘:3}
L1 =ListEnumerate (d,2))# <class ' list ';: [(2, 'Shenzhen'), (3, 'Guangzhou'), (4, 'Zhuhai‘)]
s =‘Shenzhen1800million people‘
L1 =ListEnumerate (s,1))# <class ' list ';: [(1, 'Deep'), (2, 'Zhen'), (3, ' 1 '), (4, ' 8 '), (5, ' 0 '), (6, ' 0 '), (7, ') 'Million'), (8, 'People‘)]
#Traverse
List1 = ["This","Is","One","Test"]
For index, itemInchEnumerate (List1,1):
Print (Index, item)
# 1This
# 2Is
# 3 a
# 4 test
# The number of rows in the statistics file
count = 0
for indexline in enumerate (open ( "file.txt" "R"):
Count + = 1
print (count )
python3-Note-c-003-function-enumerate