我想知道什么是何时以及何时在Python中使用迭代器和生成器 [英] I want to know what is and when to use iterators and generators in Python

查看:92
本文介绍了我想知道什么是何时以及何时在Python中使用迭代器和生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我开始学习python的bascis,但我遇到了Iterable和Generator这两个术语,我有一些困难需要知道,我想知道一个简单的定义或者关于这两个术语的例子,我的意思是使用它们的目的是什么以及何时使用它们。

谢谢。



< b>我尝试了什么:



i为迭代器尝试了一些代码,它看起来很容易但是生成器我很困惑..

Hello ,
i'm starting to learn the bascis of python , yet i come across the terms Iterable and Generator ,i'm having some difficulties to understend and i want to know a simple definition or exemples about those 2 terms , i mean what is the purpose of using them and when to use them .
Thank you .

What I have tried:

i tried some codes for iterators , its seems easy but generators i'm confused ..

推荐答案

请参阅 Python教程 - Python 3.4.5文档 [ ^ ]和Glossary - Python 3.4.5文档 [ ^ ]。
See The Python Tutorial — Python 3.4.5 documentation[^] and Glossary — Python 3.4.5 documentation[^].


这篇关于我想知道什么是何时以及何时在Python中使用迭代器和生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆