可以通过 isinstance(obj, Iterator) (需要事先 from collections import Iterable ) 来判断对象是否迭代器. 迭代到没有值了返回 StopIteration 错误.
確定! 回上一頁