Python assignment operation method sharing
- 2020-04-02 09:49:05
- OfStack
I. sequence assignment:
X, y, z = 1, 2, 3
We can think of it as :x = 1,y = 2,z = 3
Ii. Link assignment:
X is equal to y is equal to 1
The print id (x)
The print id (y)
And if you look at it, the two executions are the same. Indicates that the variables x and y are both reference addresses that store the integer object 1.
Incremental assignment.
So let's say that x is equal to x plus 1 we could change that to x plus 1
With the three points above, I believe you have a good understanding of the assignment operation.