按索引迭代python

代码示例

23
0

python3遍历索引

items=['baseball','basketball','football']
for index, item in enumerate(items):
    print(index, item)
0
0

python for循环索引

# Creates two variables; An index (num), and the value at that index (line)
for num, line in enumerate(lines):
    print("{0:03d}: {}".format(num, line))

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................