国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 除法 /與//在2.7*和3.*版本的區別

2019-11-06 06:49:22
字體:
來源:轉載
供稿:網友
up votedown voteaccepted

In Python 3.0, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division, and the latter is floor division, sometimes also called integer division.

In Python 2.2 or later in the 2.x line, there is no difference for integers unless you perform a from __future__ import division, which causes Python 2.x to adopt the behavior of 3.0

Regardless of the future import, 5.0 // 2 will return 2.0 since that's the floor division result of the Operation.

You can find a detailed description at https://docs.python.org/whatsnew/2.2.html#pep-238-changing-the-division-operator

It helps to clarify for the Python 2.x line, / is neither floor division nor true division. The current accepted answer is not clear on this. / is floor division when both args are int, but is true division when either or both of the args are float.

The above tells a lot more truth, and is a lot more clearer than the 2nd paragraph in the accepted answer.

from: http://stackoverflow.com/questions/183853/in-python-2-what-is-the-difference-between-and-when-used-for-division


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 榆社县| 财经| 镇原县| 浮梁县| 信宜市| 彭水| 二手房| 南丹县| 永安市| 马龙县| 阜阳市| 三门峡市| 奎屯市| 太仆寺旗| 金昌市| 黄大仙区| 聂拉木县| 马尔康县| 钟祥市| 涡阳县| 景泰县| 兴义市| 杭州市| 醴陵市| 呼图壁县| 江山市| 湛江市| 禄丰县| 墨江| 乡宁县| 阳原县| 宁武县| 门头沟区| 阿图什市| 萨迦县| 绥滨县| 清流县| 义乌市| 天长市| 寻乌县| 梧州市|