Python整数用++递增 [英] Python integer incrementing with ++

查看:26
本文介绍了Python整数用++递增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我回顾我在 VB6 的日子并想什么现代语言不允许用双加号递增时,我总是自笑?":

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++

令我惊讶的是,我在 Python 文档中找不到任何关于此的信息.我真的必须服从number = number + 1吗?人们不使用 ++/-- 符号吗?

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?

推荐答案

Python 不支持 ++,但你可以这样做:

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

number += 1

这篇关于Python整数用++递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆