Behaviour of increment and decrement operators in Python
问题 I notice that a pre-increment/decrement operator can be applied on a variable (like ++count ). It compiles, but it does not actually change the value of the variable! What is the behavior of the pre-increment/decrement operators (++/--) in Python? Why does Python deviate from the behavior of these operators seen in C/C++? 回答1: ++ is not an operator. It is two + operators. The + operator is the identity operator, which does nothing. (Clarification: the + and - unary operators only work on