WPS表格基础教程入门篇_wps使用技巧(wps表格电脑教程初学者)
659
2022-05-30
环境信息
ModelArts
Notebook - pytorch1.4-cuda10.1-cudnn7-ubuntu18.04
JupyterLab - Notebook - Conda-python3
collections 判断实例是否为可迭代对象或迭代器
from collections.abc import Iterable
# 可迭代对象中需要实现 __iter__ 或者 __getitem__ # list() 是 可迭代对象吗? isinstance(list(),Iterable) True
from collections.abc import Iterator
# 迭代器 __iter__ __next__ stopiteration # list()是迭代器吗? isinstance(list(),Iterator) False
# iter(list())是迭代器吗? isinstance(iter(list()),Iterator) True
help
help(iter) Help on built-in function iter in module builtins: iter(...) iter(iterable) -> iterator iter(callable, sentinel) -> iterator Get an iterator from an object. In the first form, the argument must supply its own iterator, or be a sequence. In the second form, the callable is called until it returns the sentinel.
help(Iterator) elp on class Iterator in module collections.abc: class Iterator(Iterable) | Method resolution order: | Iterator | Iterable | builtins.object | | Methods defined here: | | __iter__(self) | | __next__(self) | Return the next item from the iterator. When exhausted, raise StopIteration ......
help(Iterable) Help on class Iterable in module collections.abc: class Iterable(builtins.object) | Methods defined here: | | __iter__(self) ......
相关链接
Python入门篇
Python进阶篇
Python应用篇
帮助文档-AI开发平台ModelArts
【生长吧!Python】有奖征文火热进行中
备注
欢迎各位同学一起来交流学习心得^_^
在线课程、沙箱实验、认证、论坛和直播,其中包含了许多优质的内容,推荐了解与学习。
AI开发平台ModelArts Python
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。