循环列表。 [英] Loop in list.

查看:106
本文介绍了循环列表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种类型的结构来自哪里:


mat = ['a''为我的范围(3)]?


这将生成一个包含三个元素的列表但是

我在任何一本书中都没有看到它的参考。

解决方案

Jim写道:

这种类型的结构来自哪里:

mat = [''a''对于我在范围(3)]?

这将产生一个包含三个元素的列表,但是我在任何一本书中都没有看到它的参考。




它被称为列表理解。因为我不知道你的意思是什么书,所以我不能说它是否覆盖在那里。


-

Diez B. Roggisch


Jim写道:

这种类型的结构来自哪里:

mat = [''''为我的范围(3)]?

这会产生一个三个元素的列表但是
我在任何一本书中都没有看到它的参考。



它被称为列表理解它出现在Python 2.0中。

http ://www.amk.ca/python/2.0/index.h...00000000000000


Jeremy Jones


"吉姆" < JT *** @ att.net>写道:

这种类型的结构来自哪里:

mat = [''''为我的范围(3)]?br这将生成一个包含三个元素的列表,但是我没有在任何一本书中看到它的参考。




它被称为列表理解,并在Python 2.0中添加。

http://www.amk.ca/python/2.0/index.h...00000000000000
http://docs.python.org/tut/node7.htm...00000000000000
http://docs.python.org/ref/lists.html


Python 2.4引入了一种称为生成器表达式的变体:

http://www.python.org/doc/2.4/whatsnew/node4.html
http://www.python.org/peps/pep-0289.html
http://docs.python.org/ref/ genexpr.html


< / F>


Where did this type of structure come from:

mat = [''a'' for i in range(3)] ?

This will produce a list of three elements but
I don''t see reference for it in any of the books.

解决方案

Jim wrote:

Where did this type of structure come from:

mat = [''a'' for i in range(3)] ?

This will produce a list of three elements but
I don''t see reference for it in any of the books.



Its called a list-comprehension. And as I don''t know what books you mean, I
can''t say if its covered there or not.

--
Regards,

Diez B. Roggisch


Jim wrote:

Where did this type of structure come from:

mat = [''a'' for i in range(3)] ?

This will produce a list of three elements but
I don''t see reference for it in any of the books.


It''s called a list comprehension and it appeared in Python 2.0.

http://www.amk.ca/python/2.0/index.h...00000000000000

Jeremy Jones


"Jim" <jt***@att.net> wrote:

Where did this type of structure come from:

mat = [''a'' for i in range(3)] ?

This will produce a list of three elements but
I don''t see reference for it in any of the books.



it''s called "list comprehension", and was added in Python 2.0.

http://www.amk.ca/python/2.0/index.h...00000000000000
http://docs.python.org/tut/node7.htm...00000000000000
http://docs.python.org/ref/lists.html

Python 2.4 introduces a variation called "generator expressions":

http://www.python.org/doc/2.4/whatsnew/node4.html
http://www.python.org/peps/pep-0289.html
http://docs.python.org/ref/genexpr.html

</F>


这篇关于循环列表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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