def countdown(n): while n > 0: yield n n -= 1 # 创建生成器对象 generator = countdown(5) # 通过迭代生成器获取值 print(next(generator)) # 输出: 5 ...
確定! 回上一頁