python 학습 숙제 노트 4

719 단어 python3.6
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time     : 2018/8/16 10:20
# @Author   : 

#    
#              Iterable  (     )
from collections import Iterable

print(isinstance([], Iterable))  # ===> True
print(isinstance("", Iterable))  # ===> True
print(isinstance((x for x in range(10)), Iterable))  # ===> True
print(isinstance(100, Iterable))  # ===> False

#     next()                    Iterator  (     )
from collections import Iterator

print(isinstance((x for x in range(10)), Iterator))  # ===> True
print(isinstance(([]), Iterator))  # ===> False

#      (Iterable)     (Iterator)         
print(isinstance(iter([]), Iterator))  # ===> True

좋은 웹페이지 즐겨찾기