标签:字符串 for pytho ext 可迭代对象 ons __iter__ import 显示
from collections import Iterable,Iterator
def generator():
for i in range(10):
yield i
st = ‘‘
li = []
di = {}
ge = generator()
isinstance(st, Iterable), isinstance(li, Iterable), isinstance(di, Iterable), isinstance(ge, Iterable)
结果为:
(True, True, True, True)
isinstance(st,Iterator), isinstance(li, Iterator), isinstance(di, Iterator), isinstance(ge, Iterator)
结果为:
(False, False, False, True)
标签:字符串 for pytho ext 可迭代对象 ons __iter__ import 显示
原文地址:https://www.cnblogs.com/geoffreyone/p/9892481.html