python最新版教程第46讲函数VI课后作业有关的疑问
动动手第0题import time
def delay(func):
def call_func():
time.sleep(1)
func()
return call_func
def fib():
back1, back2 = 0, 1
@delay
def func():
nonlocal back1, back2
back1, back2 = back2, back1 + back2
print(back1, end=' ')
return func
def get_fib(n):
f = fib()
for i in range(n):
f()
n = int(input("请输入需要获取的斐波那契数:"))
get_fib(n)
这其中的 back1, back2 = back2, back1 + back2是什么意思,求大佬回答 back1, back2 = back2, back1 + back2意思:
swap = back1
back1 =back2
back2 =swap + back2 chinajz 发表于 2023-2-7 11:45
back1, back2 = back2, back1 + back2意思:
谢谢
页:
[1]