티스토리 뷰

PL/Python

[Python] iter(), next()

SweetDev 2021. 10. 7. 14:52
>>> import random
>>> it = iter(lambda : random.randint(0, 5), 2)
>>> next(it)
0
>>> next(it)
3
>>> next(it)
1
>>> next(it)
Traceback (most recent call last):
  File "<pyshell#37>", line 1, in <module>
    next(it)
StopIteration

'PL > Python' 카테고리의 다른 글

[Python] bin, hex 변환  (0) 2021.11.12
[Python] bound/unbound 차이  (0) 2021.11.07
[Python] sort key값  (0) 2021.08.12
[Python][numpy] colon, comma in array  (0) 2021.08.11
[Python] for문에서 array(list)의 데이터 변형  (0) 2021.08.05
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함