码迷,mamicode.com
首页 > 编程语言 > 详细

python--迭代器

时间:2018-03-10 00:18:34      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:iter   str   blog   pos   python   string   except   class   没有   

挨个访问,直到没有出现StopIteration错误。

while true:

  try:

    each=next(it)

  except StopIteration:

    break

  print(each)

for each in string:

  print(each)

 

python--迭代器

标签:iter   str   blog   pos   python   string   except   class   没有   

原文地址:https://www.cnblogs.com/y1995/p/8536709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!