演示生成器

#演示生成器
#!/usr/local/bin/python2.5
def genner(n):
	for i in range(n):
		yield i ** 2
x = genner(5)
print x.next()
print x.next()
print x.next()
print x.next()
print x.next()

编程技巧