IT Log

[Python] iterable 본문

Python

[Python] iterable

newly0513 2021. 6. 6. 20:52
728x90
반응형

iterable : 한 번에 하나씩 돌려줄 수 있는 객체로, <list, str, tuple, dict이거나 File>등

 

 

※ 해당 객체가 iterable인지 아닌지 확인하는 방법

> 해당 객체가 iterable이면 True를 반환하고, 아니면 False를 반환

obj = [1,2,3,4,5]

import collections
isinstance(obj, collections.abc.Iterable)

또는 

from collections.abc import Iterable
isinstance(obj, Iterable)

 

 

 

 

728x90
반응형

'Python' 카테고리의 다른 글

[Python] 정규 표현식  (0) 2022.05.24
[Python] Ray Tutorial  (0) 2021.06.07
[Python] Multiline String (여러줄 문자열)  (0) 2021.06.06
[Python] WARNING: The script flask is installed in  (0) 2021.06.06
[Python] Selenium (Keys)  (1) 2021.06.06
Comments