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 | 尝试它 » |