再简单的代码也要亲手敲一遍
Topic sourcedef Iterator(): i=1 while True: yield i i+=1 o=Iterator for t in o(): print(t)
有点没太明白呢,for t in o() 是什么意思?
for t in o()的意思的调用自定义函数,如果改成 def Iterator(): i=1 while True: yield i i+=1 print (i) 你可能就明白了
- 1
def Iterator(): i=1 while True: yield i i+=1 o=Iterator for t in o(): print(t)
有点没太明白呢,for t in o() 是什么意思?
for t in o()的意思的调用自定义函数,如果改成 def Iterator(): i=1 while True: yield i i+=1 print (i) 你可能就明白了
翁岚敏
输出全体正整数
def Iterator(): i=1 while True: yield i i+=1 o=Iterator for t in o(): print(t)