Python integer incrementing with ++ [duplicate]

发布于 2021-01-29 16:26:30

This question already has answers here :

Behaviour of increment and decrement operators in
Python
(9 answers)

Closed 10 months ago.

I’ve always laughed to myself when I’ve looked back at my VB6 days and
thought, “What modern language doesn’t allow incrementing with double plus
signs?”:

number++

To my surprise, I can’t find anything about this in the Python docs. Must I
really subject myself to number = number + 1? Don’t people use the ++/--
notation?

关注者
0
被浏览
38
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    Python doesn’t support ++, but you can do:

    number += 1
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看