每天CookBook之Python-066

  • enumerate的使用
my_list = ['a', 'b', 'c']
for idx, val in enumerate(my_list, 1):
    print(idx, val)

out

1 a
2 b
3 c
posted @ 2016-07-22 20:59  4Thing  阅读(90)  评论(0编辑  收藏  举报