久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

究竟什么是迭代器、可迭代和迭代?

What exactly are iterator, iterable, and iteration?(究竟什么是迭代器、可迭代和迭代?)
本文介紹了究竟什么是迭代器、可迭代和迭代?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

Python中iterable"、iterator"、iteration"最基本的定義是什么?

What is the most basic definition of "iterable", "iterator" and "iteration" in Python?

我已經閱讀了多個定義,但我無法確定確切的含義,因為它仍然無法理解.

I have read multiple definitions but I am unable to identify the exact meaning as it still won't sink in.

有人可以幫我用外行術語來解釋這 3 個定義嗎?

Can someone please help me with the 3 definitions in layman terms?

推薦答案

迭代是一個總稱,一個接一個地取某事物的每一項.每當您使用循環(顯式或隱式)遍歷一組項目時,這就是迭代.

Iteration is a general term for taking each item of something, one after another. Any time you use a loop, explicit or implicit, to go over a group of items, that is iteration.

在 Python 中,iterableiterator 有特定的含義.

In Python, iterable and iterator have specific meanings.

iterable 是具有 __iter__ 方法的對象,該方法返回 iterator,或定義 __getitem__ 可以采用從零開始的順序索引的方法(并在索引不再有效時引發 IndexError ).所以 iterable 是一個可以從中獲取 iterator 的對象.

An iterable is an object that has an __iter__ method which returns an iterator, or which defines a __getitem__ method that can take sequential indexes starting from zero (and raises an IndexError when the indexes are no longer valid). So an iterable is an object that you can get an iterator from.

iterator 是具有 next (Python 2) 或 __next__ (Python 3) 方法的對象.

An iterator is an object with a next (Python 2) or __next__ (Python 3) method.

每當你在 Python 中使用 for 循環、map 或列表推導等時,都會自動調用 next 方法從iterator中獲取每一項,從而經歷iteration的過程.

Whenever you use a for loop, or map, or a list comprehension, etc. in Python, the next method is called automatically to get each item from the iterator, thus going through the process of iteration.

本教程的迭代器部分和標準類型頁面的迭代器類型部分.了解基礎知識后,請嘗試函數式編程 HOWTO 的迭代器部分.

A good place to start learning would be the iterators section of the tutorial and the iterator types section of the standard types page. After you understand the basics, try the iterators section of the Functional Programming HOWTO.

這篇關于究竟什么是迭代器、可迭代和迭代?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 天天干狠狠操 | 久久99精品久久久久久 | 麻豆国产精品777777在线 | 成人中文字幕在线观看 | 久久日韩精品一区二区三区 | 欧美一级电影免费观看 | 99视频免费看 | 4hu最新网址| 国产香蕉视频 | 在线一区观看 | 亚洲免费网| 亚洲一区在线日韩在线深爱 | 免费人成激情视频在线观看冫 | 91av在线视频观看 | 国产精品久久久久久久岛一牛影视 | 色天堂影院 | 欧美精品一区二区三区一线天视频 | 91视视频在线观看入口直接观看 | 欧美一区二区三区在线看 | 国产成在线观看免费视频 | 国产一区二区三区久久久久久久久 | 精品欧美久久 | av资源中文在线天堂 | av中文字幕在线播放 | 超碰伊人 | 国产精品视屏 | av网站免费在线观看 | 成年视频在线观看福利资源 | 99视频精品 | 日韩一区二区黄色片 | 91看片网 | 久草青青草| 久久久久无码国产精品一区 | 亚洲精品99| 欧美日韩亚洲一区 | 久久久久久久久99精品 | 精精国产xxxx视频在线野外 | 日韩影院一区 | 91免费看片| 美女视频黄的 | 九九导航 |