python from __future__ import division
来源:互联网 发布:苹果电脑不能淘宝付款 编辑:程序博客网 时间:2024/06/06 02:17
from __future__ import division
导入python未来支持的语言特征division(精确除法),当我们没有在程序中导入该特征时,"/"操作符执行的是截断除法(Truncating Division),当我们导入精确除法之后,"/"执行的是精确除法,如下所示:
---------------------------------------------------------------------------------------------
>>> 3/40
>>> from __future__ import division
>>> 3/4
0.75
--------------------------------------------------------------------------------------------
导入精确除法后,若要执行截断除法,可以使用"//"操作符:
--------------------------------------------------------------------------------------------
>>> 3//4
0
>>>
>>> 3//4
0
>>>
--------------------------------------------------------------------------------------------
一些将来特征如下:
PEP:Python Enhancement Proposals
可以在这个地方找到很多PEP:http://www.python.org/dev/peps/ 里面还能看到许多提议的动机
比如有division:
The current division (/) operator has an ambiguous meaning for numerical arguments:
it returns the floor of the mathematical result of division if the arguments are ints or longs, but it returns a reasonable approximation of the division result if the arguments are floats or complex.
This makes expressions expecting float or complex results error-prone when integers are not expected but possible as inputs.
- python from __future__ import division
- python from __future__ import division
- python from __future__ import division
- Python from __future__ import division
- python中的python from __future__ import division
- from __future__ import division
- Python自然语言处理小问题之from __future__ import division
- Python_(__future__.py源代码) 可以引用from __future__ import division
- 关于python 中的__future__模块(from __future__ import ***)
- Python 基础 —— from __future__ import
- from __future__ import unicode_literals
- from __future__ import absolute_import
- from __future__ import absolute_import
- from __future__ import print_function
- from __future__ import 作用
- from __future__ import division 报错,不存在该模块。原因是。。。。
- Python基础之--from __future__ import unicode_literals作用
- python的import __future__作用
- 禁用光标和调用函数接口的emacs配置
- Map执行时的RecordWriter实现之NewOutputCollector
- 结合typedef更为直观的应用函数指针
- html的第三课
- Merge/Split PDF files in Linux
- python from __future__ import division
- android控件06 ImageButton
- 用Oauth2.0同时验证新浪,人人和腾讯
- Boost 下载地址
- Linux管理常用命令
- 如何用ant来启动和停止tomcat以运行web项目
- Android中Cursor关闭的问题
- 函数递归调用详解
- 浅谈几位导师