python - increment operator++i 不会在 python 中导致错误

标签 python operators increment

<分区>

既然python不支持自增运算符++,那为什么给变量加前缀不报错呢。示例:

i = 3
++i

在交互式控制台上打印 3。这是为什么?

最佳答案

看看 - 这只是一个标志:

>>> i = 3
>>> +i
3
>>> ++i
3
>>> +++i
3
>>> -i
-3
>>> --i
3
>>> ---i
-3

关于python - increment operator++i 不会在 python 中导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18506579/

相关文章:

python - 如何增加字母数字值

用于组装的 python curl

Python 没有找到 System32

PHP - $variable = value1 或 value2

c - 如果我们将最大的可表示整数加一,结果是否为负数?

sql - 添加和递增日期和时间 (Postgresql)

python - 如何将两个列表合并为 python 中的一系列列?

python - 使用 Union 类型设置默认值

JavaScript 字符串与 & 运算符相等

c - 为什么在 C 中不允许使用表达式 c=(a+b)++?