【PYTHON3學習】-三種生成奇數列迭代器(iterator)的方法

import itertools
#generator
def odds():
	n=1
	while True:
		yield n
		n=n+2
		
odditer=filter(lambda x:x%2!=0,itertools.count(1))
odd_num_seq = itertools.count(1, 2)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章