【发布时间】:2016-05-03 20:14:01
【问题描述】:
我做了一些代码,基本上可以找到句子中单词的索引,但我真的不明白我做了什么以及枚举的功能是什么?
sentence = ['The', 'cat','sat', 'on', 'the', 'mat']
for index, word in enumerate(sentence):
print (index, word)
【问题讨论】:
-
Stack Overflow 的目的不是教程。在网上很容易找到关于
enumerate在 Python 中的作用的信息。
标签: python python-3.x enumerate