python中next的用法

>>> a = iter('abcd')
>>> next(a)
'a'
>>> next(a)
'b'
>>> next(a)
'c'
>>> next(a)
'd'
>>> next(a)
Traceback (most recent call last):
 File "<pyshell#18>", line 1, in <module>
  next(a)
StopIteration

  

posted @ 2020-01-13 16:54  瘋耔  阅读(1747)  评论(0编辑  收藏  举报
跳至侧栏