Augmented assignment(增量赋值/复合赋值)是编程里的写法:把“运算 + 赋值”合并成一个操作符,例如 x += 1 等价于 x = x + 1。常见形式包括 +=、-=、*=、/=、%=、<<=、&= 等。(在不同语言中细节可能略有差异。)
/ɔːɡˈmɛntɪd əˈsaɪnmənt/
I used augmented assignment to add 1 to the counter.
我用增量赋值把计数器加了 1。
In Python, augmented assignment like list += items may modify the original list in place, which can affect other references to it.
在 Python 中,像 list += items 这样的增量赋值可能会原地修改原列表,从而影响对它的其他引用。
augmented 源自拉丁语 augmentare(“增加、扩充”);assignment 来自 assign(“分配、指派”),在编程语境中指“给变量赋值”。合起来就是“带有额外运算的赋值方式”。
+= 等增量赋值的行为与注意事项 += 等复合赋值运算符 +=、*= 等复合赋值运算符的用法