enumerate
作者:互联网
>>>seasons = ['Spring', 'Summer', 'Fall', 'Winter']
>>> list(enumerate(seasons)) # 配个下标形成对儿,默认从0开始
[(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
>>> list(enumerate(seasons, start=1)) # 下标从 1 开始
[(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]
标签:Summer,Winter,Spring,enumerate,Fall,seasons 来源: https://www.cnblogs.com/pjishu/p/10545688.html