Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
既然python中不支持自增运算符++,为什么在给变量加前缀的时候不会报错。例子:
i = 3 ++i
在交互式控制台上打印 3。这是为什么?
Take a look - it's just a sign:
>>> i = 3 >>> +i 3 >>> ++i 3 >>> +++i 3 >>> -i -3 >>> --i 3 >>> ---i -3
Python treats ++i as +(+i), that would compile fine, and print the same value as of i.
++i
+(+i)
i