码迷,mamicode.com
首页 > 其他好文 > 详细

迭代器

时间:2018-10-30 00:58:55      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:str   dict   ext   lis   port   函数调用   循环   for   rom   

1、可直接作用于for循环的对象统称为可迭代对象:Iterable

2、isinstance函数:判断是否是可迭代对象isinstance([],Iterable)(需先from collections import Iterable)

3、迭代器:可以被next()函数调用并不断地返回下一个值的对象

4、iter()函数:把list、dict、str等可迭代对象变成迭代器

迭代器

标签:str   dict   ext   lis   port   函数调用   循环   for   rom   

原文地址:https://www.cnblogs.com/Treelight/p/9874215.html

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