enumerate()
函數是會返回index(下標)和value(值)的函數 實際上,enumerate()
在每次循環中,返回的是一個包含兩個元素的定值表(tuple),兩個元素分別賦予index和value。
實例
文檔
"""Docstring:enumerate(iterable[, start]) -> iterator for index, value of iterableReturn an enumerate object. iterable must be another object that supportsiteration. The enumerate object yields pairs containing a count (fromstart, which defaults to zero) and a value yielded by the iterable argument.enumerate is useful for obtaining an indexed list: (0, seq[0]), (1, seq[1]), (2, seq[2]), ...Type: type"""新聞熱點
疑難解答