小编Kev*_*uts的帖子

Python3:枚举函数中的start参数如何工作?

我有一个清单。我想从中处理列表中的项目variable starting point

lines = ["line 0", ..., "line 25", ...]
cursor = 25

for i, line in enumerate(lines, start=cursor):
    print("cursor is at:", cursor)
    print("start line is:", lines[cursor])
    print("actual line is:", line)
Run Code Online (Sandbox Code Playgroud)

输出:

cursor is at: 25
start line is: line 25
actual line is: line 0
...
Run Code Online (Sandbox Code Playgroud)

我希望enumeratecursor这里开始,但是它从开始0


我敢肯定我误解了一些东西,但是我真的很想了解如何enumerate改进我的Python。

python list enumerate python-3.x

0
推荐指数
1
解决办法
88
查看次数

标签 统计

enumerate ×1

list ×1

python ×1

python-3.x ×1