What does enumerate() mean?

后端 未结 5 594
别跟我提以往
别跟我提以往 2020-11-22 01:24

What does for row_number, row in enumerate(cursor): do in Python?

What does enumerate mean in this context?

5条回答
  •  长情又很酷
    2020-11-22 01:54

    The enumerate function works as follows:

    doc = """I like movie. But I don't like the cast. The story is very nice"""
    doc1 = doc.split('.')
    for i in enumerate(doc1):
         print(i)
    

    The output is

    (0, 'I like movie')
    (1, " But I don't like the cast")
    (2, ' The story is very nice')
    

提交回复
热议问题