Python 赋值运算符
Python 赋值运算符
赋值运算符用于给变量赋值:
运算符 | 实例 | 等同于 | 试一试 |
---|---|---|---|
= | x = 5 | x = 5 | 亲自试一试 » |
+= | x += 3 | x = x + 3 | 亲自试一试 » |
-= | x -= 3 | x = x - 3 | 亲自试一试 » |
*= | x *= 3 | x = x * 3 | 亲自试一试 » |
/= | x /= 3 | x = x / 3 | 亲自试一试 » |
%= | x %= 3 | x = x % 3 | 亲自试一试 » |
//= | x //= 3 | x = x // 3 | 亲自试一试 » |
**= | x **= 3 | x = x ** 3 | 亲自试一试 » |
&= | x &= 3 | x = x & 3 | 亲自试一试 » |
|= | x |= 3 | x = x | 3 | 亲自试一试 » |
^= | x ^= 3 | x = x ^ 3 | 亲自试一试 » |
>>= | x >>= 3 | x = x >> 3 | 亲自试一试 » |
<<= | x <<= 3 | x = x << 3 | 亲自试一试 » |