官术网_书友最值得收藏!

Python 2 versus Python 3 division

While most Python 2.7 code is compatible with 3.x code, you can see that certain things don't carry over well. For example, Python 2 truncates the output of division calculations:

# Python 2
>>> 7/2
3

Python 3, as the following shows, provides the remainder when dividing. This is important to remember, as the code you're writing will break if it uses features or side effects of a particular version but is run on a different version:

# Python 3
>>> 7/2
3.5
主站蜘蛛池模板: 绥阳县| 明水县| SHOW| 德阳市| 盐山县| 巴林左旗| 乌拉特前旗| 滦平县| 潼南县| 中卫市| 岳西县| 荆州市| 怀化市| 永善县| 班玛县| 白玉县| 精河县| 玉树县| 彭阳县| 日土县| 汉阴县| 蓬安县| 东平县| 永平县| 鹤壁市| 高密市| 城固县| 广灵县| 和政县| 原平市| 利津县| 会理县| 三亚市| 思茅市| 唐海县| 西乌珠穆沁旗| 泸州市| 乌恰县| 柳林县| 红河县| 上栗县|