In Python,+= means to add an assignment operator, which is a kind of assignment operator.
The "+=" operator can add first and then assign the result to the variable on the left side of the operator.
Grammar:
x += y
This is equivalent to:
x = x + y
Extended reading:
The assignment operator is used to pass the right value to the left variable; You can directly give the right value to the left variable, or you can do some operations, such as addition, subtraction, multiplication and division, function call, logical operation, and then give it to the left variable.
The most basic assignment operator in Python is equal sign =; Combined with other operators, = can also extend the more powerful assignment operator.
Basic assignment operator
= is the most common and basic assignment operator in Python, which is used to assign the value of one expression to another variable.
Extended assignment operator
= can also be combined with other operators to expand into a more powerful assignment operator. The extended assignment operator will make the writing of assignment expressions more elegant and convenient. Next, I will give you a detailed introduction.
= the most basic assignment operation, for example: x=y, equivalent form: x = y.
+= plus assignment, for example: x += y, equivalent form: x = x+y.
-= subtraction assignment, for example: x-=y, equivalent form: x = x-y.
* = multiplication assignment, for example: x *=y, equivalent form: x = x * y.
/= partition assignment, for example: x/=y, equivalent form: x = x/y.
% = take the remainder to assign value, for example: x %= y, equivalent form: x = x% y.
* * = power assignment, for example: x **= y, equivalent form: x = x * * y.
//= integer assignment, for example: x //= y, equivalent form: x = x//y/y.
& amp= Bitwise and assignment, for example: x &;; = y, equivalent form: x = x &;; y .
| = bitwise or assignment, for example: x |= y, equivalent form: x = x | y.
= Bitwise XOR assignment, for example: x ^= y, equivalent form: x = x y.
& lt& lt= left shift assignment, for example: X.
& gt& gt= right shift assignment, for example: x >>= y, equivalent form: x = x >>y, where y refers to the number of digits shifted to the right.