2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pythonの`next`関数は、iteratorから次の要素を取得してくれるものでした

Last updated at Posted at 2022-02-13

pythonのnext関数は、iteratorから次の要素を取得してくれるものでした

test.py
list_a = [1,2,3,4,5]
iter_a = iter(list_a)
print(next(iter_a))
print(next(iter_a))
print(next(iter_a))
print(next(iter_a))
print(next(iter_a))

以下のように実行する

$ python test.py 
1
2
3
4
5

socket通信でiteratorを扱う時とかに出てくる様子

参考

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?