1 a, b = 3, 4 2 c, d = 3, 4 3 4 a, b = b, a + b 5 c = d 6 d = c + d 7 print(a, b, c, d)
输出:
4 7 4 8
因为a, b和b, a + b都是元祖(tuple)
先计算(b, a + b)的元祖为(4, 7)然后将该元祖赋值给(a, b)
其等于以下代码:
1 a, b = 3, 4 2 c = (b, a + b) 3 a, b = c
1 a, b = 3, 4 2 c, d = 3, 4 3 4 a, b = b, a + b 5 c = d 6 d = c + d 7 print(a, b, c, d)
输出:
4 7 4 8
因为a, b和b, a + b都是元祖(tuple)
先计算(b, a + b)的元祖为(4, 7)然后将该元祖赋值给(a, b)
其等于以下代码:
1 a, b = 3, 4 2 c = (b, a + b) 3 a, b = c