closure1 [Big data&Python] iterator, generator, generator expression, closure, decorator, jupyter notebook 1. iterator iterator는 next()를 사용 하여 다음 요소를 가져올 수 있는 객체를 의미한다. iterator를 사용할 수 있는 데이터 구조는 list, tuple, dictionary, set 등이 있다. for문으로 값을 읽어 올 수 있으면 iterable(반복 가능한) 하다고 할 수 있다. next 함수로 다음 요소를 가져 올 수 없으면 iterator가 아니다. liter, tuple, dictinary, set을 iter()로 형변환하여 사용한다. 인덱스를 사용해서 받아오는 것이 아니라 요소를 불러오고 다음 요소에 접근하는 방식이다. 1.1 iterator 예제 iter()로 형변환 한 it을 출력 하면 list_iterator object가 출력됩니다. next()로 값을 하나.. Coding 공부/Big data & Python 2024. 3. 9. 이전 1 다음 728x90 반응형