python-small-examples/md/47.md at master · data-python/python-small-examples

Latest commit

File metadata and controls

19 lines (16 loc) · 294 Bytes

@author jackzhenguo
@desc 
@date 2019/3/4

47 枚举对象  

返回一个可以枚举的对象,该对象的next()方法将返回一个元组。

In [1]: s = ["a","b","c"]
    ...: for i ,v in enumerate(s,1):
    ...:     print(i,v)
    ...:
1 a
2 b
3 c