a, b = 3, 4
c, d = 3, 4 a, b = b, a + b
c = d
d = c + d
print(a, b, c, d)
输出:
4 7 4 8
因为a, b和b, a + b都是元祖(tuple)
先计算(b, a + b)的元祖为(4, 7)然后将该元祖赋值给(a, b)
其等于以下代码:
a, b = 3, 4
c = (b, a + b)
a, b = c
2024-04-01 12:45:10
a, b = 3, 4
c, d = 3, 4 a, b = b, a + b
c = d
d = c + d
print(a, b, c, d)
输出:
4 7 4 8
因为a, b和b, a + b都是元祖(tuple)
先计算(b, a + b)的元祖为(4, 7)然后将该元祖赋值给(a, b)
其等于以下代码:
a, b = 3, 4
c = (b, a + b)
a, b = c