相关疑难解决方法(0)

Python:next()函数

我正在从一本书中学习Python,我遇到了这个例子:

M = [[1,2,3],
     [4,5,6],
     [7,8,9]]

G = (sum(row) for row in M) # create a generator of row sums
next(G) # Run the iteration protocol
Run Code Online (Sandbox Code Playgroud)

由于我是一个绝对的初学者,并且作者没有提供对示例或next()函数的任何解释,我不明白代码在做什么.

python sum next

42
推荐指数
2
解决办法
5万
查看次数

标签 统计

next ×1

python ×1

sum ×1