久久久久久久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 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 亚洲综合视频 | 黄网站免费入口 | 国产一级片免费在线观看 | 亚洲精品在线免费观看视频 | 91精品免费视频 | 日本成人在线免费视频 | 一区二区视频在线观看 | 亚洲色图婷婷 | 久久国产精品一区二区三区 | 午夜tv免费观看 | 亚洲成人中文字幕 | 国产精品久久久久久久久免费高清 | 亚洲国产精品一区二区第一页 | 日韩毛片| 91精品久久久久久久久久小网站 | 亚洲黄色一级 | 香蕉久久久久久 | 福利一区二区在线 | 伊人热久久 | 欧美一区二区三区在线观看 | 国产精品毛片一区二区三区 | 成人亚洲| 狠狠干天天干 | 日韩精品一区二区在线观看 | 激情久久久久 | 男女在线网站 | 一级黄片一级毛片 | 在线中文字幕视频 | 久久久婷 | 成人污污视频 | 免费精品视频 | 国产精品久久久久久久久久久久 | 二区国产 | 免费一区在线 | 国产偷录叫床高潮录音 | 欧美日韩亚洲国产综合 | 午夜一区二区三区在线观看 | 久色一区 | 久久久综合精品 | 97超碰在线播放 | 日韩在线观看网站 |