forked from eastlakeside/interpy-zh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5543d2
commit 99f4bea
Showing
3 changed files
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# 可迭代对象(Iterable) | ||
|
||
一个可迭代对象是Python中任意的对象,只要它定义了可以返回一个迭代器的```__iter__```方法,或者定义了可以支持下标索引的```__getitem__```方法(这些双下划线方法会在其他章节中全面解释)。简单说,一个可迭代对象,就是任意的对象,只要它能给我们提供一个迭代器。那迭代器又是什么呢? | ||
Python中任意的对象,只要它定义了可以返回一个迭代器的```__iter__```方法,或者定义了可以支持下标索引的```__getitem__```方法(这些双下划线方法会在其他章节中全面解释),那么它就是一个可迭代对象。简单说,可迭代对象就是能提供迭代器的任意对象。那迭代器又是什么呢? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# 迭代(Iteration) | ||
|
||
用简单的话讲,它就是从某个地方(比如一个列表)取出一个元素的过程。当我们使用一个循环来遍历某个东西时,这就叫一个迭代。它是这个过程本身的名字。现在既然我们有了这些术语的基本理解,那我们开始理解生成器吧。 | ||
用简单的话讲,它就是从某个地方(比如一个列表)取出一个元素的过程。当我们使用一个循环来遍历某个东西时,这个过程本身就叫迭代。现在既然我们有了这些术语的基本理解,那我们开始理解生成器吧。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# 迭代器(Iterator) | ||
|
||
一个迭代器是任意一个对象,只要它定义了一个```next```(Python2) 或者```__next__```方法。就这么简单。这就是一个迭代器。现在我们来理解迭代(iteration) | ||
任意对象,只要定义了```next```(Python2) 或者```__next__```方法,它就是一个迭代器。就这么简单。现在我们来理解迭代(iteration) |