作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
<分区>
我找到了这样的斐波那契数列示例:
def fib(n):
a, b = 0, 1
while b < n:
print (b)
a, b = b, a+b
fib(20)
所以这是我不明白的:
a, b = 0, 1 # is just a shortcut for writing
a = 0
b = 1
对吗?
现在,遵循相同的逻辑
a, b = b, a+b #should be the same as writing
a = b
b = a+b
但这不是因为如果我那样写,输出是不同的。我很难理解为什么。有什么想法吗?
我是一名优秀的程序员,十分优秀!