Python中的enumerator 📝发布:2026-04-10 概述 enumerate 让你在遍历列表(或其他可迭代对象)时,同时拿到下标和元素. fruits = ["apple", "banana", "cherry"] for index, value in enumerate(fruits): print("下标:", index, "元素:", value) """ Output: 下标: 0 元素: apple 下标: 1 元素: banana 下标: 2 元素: cherry """