请问一下,生成器不能用装饰器装饰吗?不是迭代器就不能被装饰了吗?


def decoration(func):
    def wrapper(*args):
        i = 0
        while i <= 1:
            print(i)
            i += 1
        func(*args)
    return wrapper


@decoration
def fib_g(length):
    a, b = 0, 1

    n = 0
    while n < length:
        yield b
        a = b
        b = a + b
        n += 1
    return "done"

g = fib_g("5")
print(next(g))
print(next(g))

结果显示:TypeError: 'NoneType' object is not an iterator