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

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
主站蜘蛛池模板: 肃宁县| 鱼台县| 武夷山市| 榆社县| 康乐县| 陆河县| 平度市| 新晃| 武宣县| 铜山县| 富平县| 四会市| 永年县| 新田县| 蛟河市| 灵台县| 蒙城县| 西宁市| 无极县| 贞丰县| 永泰县| 上饶县| 虞城县| 英超| 兴仁县| 鄱阳县| 平湖市| 虎林市| 古丈县| 封开县| 滕州市| 东至县| 金华市| 岢岚县| 阿拉善左旗| 邻水| 夏津县| 和林格尔县| 山东省| 平顺县| 炎陵县|