python:practice module generator of list time jison

Posted alansuny

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python:practice module generator of list time jison相关的知识,希望对你有一定的参考价值。

content:

1:generator of list【】:
list=[x for x in range(10)]
realize:[0,1,2,3,4,5,6,7,8,9]
list=[x*2 for x in range(10)]
list=[x*x for x in range(10)]
principal function:
def f(n):
return n**3
a=[f(x) for x in range(10)]
print(a)

a=(f(x) for x in range(10))

next(a)=a.__next__()
call the generator value
invoking generator value
generator is a iterable
invoke "for loop" express generator value
for i in a:
print(i)
for equivalent next() call generator
2: create generator main two method
use ()
ues yield
for example
def generator():
yield 7

generator()
can use for loop object
have __iter__method is object set() list[],dict{},tuple(),generator()

以上是关于python:practice module generator of list time jison的主要内容,如果未能解决你的问题,请参考以下文章

python python_practice

python python_practice

python :practice function return

python: practice recurse function

python:practice built-in function

python:practice decorator calaulate_time