python 中逗号分隔符和正常赋值的计算顺序不同

Difference in evaluation order of comma separator and normal assignment in python

谁能告诉我普通赋值和逗号分隔符赋值的区别?

正常分配:

prev.next = head.next
head.next = None
head = head.next

逗号分隔符分配:

prev.next,head.next,head= head.next,None,head.next

两种情况下的执行顺序有何不同?谁能解释一下评估顺序?

提前致谢。

无论您是否正在解包,等号的右侧总是先求值再分配给左侧的值。

正在写这个:

a,b,c = 1,2,3

就像这样写

temp = (1, 2, 3)
(a, b, c) = temp

顺序固定:

An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter yielding a tuple) and assigns the single resulting object to each of the target lists, from left to right.