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

查看:71
本文介绍了使用++的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天全站免登陆