seasons = ['Spring', 'Summer', 'Fall', 'Winter'] print(list(enumerate(seasons))) for i,value in enumerate(seasons): print(i,value) 输出结果: [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] 0 Spring 1 Summer 2 Fall 3 Winter
seasons = ['Spring', 'Summer', 'Fall', 'Winter'] print(list(enumerate(seasons))) for i,value in enumerate(seasons): print(i,value) 输出结果: [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')] 0 Spring 1 Summer 2 Fall 3 Winter