from __future__ import division
>>> 3/4
0
>>> from __future__ import division
>>> 3/4
0.75
--------------------------------------------------------------------------------------------
| feature | optional in | mandatory in | effect |
|---|---|---|---|
| nested_scopes | 2.1.0b1 | 2.2 | PEP 227: Statically Nested Scopes |
| generators | 2.2.0a1 | 2.3 | PEP 255: Simple Generators |
| division | 2.2.0a2 | 3.0 | PEP 238: Changing the Division Operator |
| absolute_import | 2.5.0a1 | 2.7 | PEP 328: Imports: Multi-Line and Absolute/Relative |
| with_statement | 2.5.0a1 | 2.6 | PEP 343: The “with” Statement |
| print_function | 2.6.0a2 | 3.0 | PEP 3105: Make print a function |
| unicode_literals | 2.6.0a2 | 3.0 | PEP 3112: Bytes literals in Python 3000 |
PEP:Python Enhancement Proposals
可以在这个地方找到很多PEP:http://www.python.org/dev/peps/ 里面还能看到许多提议的动机
----------------------------------------------------------------------------
nested_scopes: 改变名空间的搜索过程
generators:使用生成器.能够产生能保存当前状态的函数.
division:精确的除法
absolute_import:包含绝对路径.方便include
with_statement:安全的打开文件
from __future__ import division的更多相关文章
- python from __future__ import division
1.在python2 中导入未来的支持的语言特征中division(精确除法),即from __future__ import division ,当我们在程序中没有导入该特征时,"/&qu ...
- 【python】只执行普通除法:添加 from __future__ import division
from __future__ import division 注意future前后是两个下划线
- python中from __future__ import division
ppython2.7版本中整数相除得出的结果不显示小数 a = 9 / 2 print(a) 输出结果: 4 此时就需要调用from __future__ import division 1 from ...
- 精确除法:from __future__ import division
在python中做除法运算,使用1/2运行结果为0,为取结果的整数部分 如果用1.0/2或1/2.0运行结果为0.5,按照浮点数的位数取结果 但是实际应用中我们需要取除法的精确结果,我们就可以在运行前 ...
- from __future__ import包的作用
__future__是python2的概念,其实是为了使用python2时能够去调用一些在python3中实现的特性 1.absolute_import from __future__ import ...
- from __future__ import absolute_import
from __future__ import absolute_import 这样以后:局部的包将不能覆盖全局的包, 本地的包必须使用相对引用了. 例: from celery import Cele ...
- from __future__ import print_function的作用
阅读代码的时候会看到下面语句: from __future__ import print_function 该语句是python2的概念,那么python3对于python2就是future了,也就是 ...
- Python底层库的函数中from __future__ import absolute_import的作用
在查看TensorFlow的底层优化器时候看到from __future__ import absolute_import 查找相关资料后发现 这个语句的意思是加入绝对引用的特征 直白的意思是,比如: ...
- from __future__ import
读代码的过程中看到的,好奇搜索了一下,其实当在我们调试别人Python代码的过程中经常会遇到一些问题,比如版本不同,代码也会有所改变,比如print函数 Python 2.7版本为 print “ ” ...
随机推荐
- 【转】每天一个linux命令(26):用SecureCRT来上传和下载文件
原文网址:http://www.cnblogs.com/peida/archive/2012/11/28/2793181.html 用SSH管理linux服务器时经常需要远程与本地之间交互文件.而直接 ...
- 使用JMeter代理服务器录制APP脚本
重点:证书的安装,需要将Jmeter安装目录下证书传送到手机,使用手机安装(不要用QQ传送给手机,手机提示无法安装,可使用网盘方式传送,可成功安装证书) (出现该错误时,需安装证书) 简单的配置教程如 ...
- 消息中间件 ActiveMQ的简单使用
一.AactiveMQ的下载和安装 1. 下载ActiveMQ 地址:http://activemq.apache.org/activemq-5152-release.html 我这里下载的是wind ...
- 【python】实例-判断用户输入数字的类型
num=input("please input the num: ") print "the number your input is: "+str(num) ...
- 创建mysql 用户并限定其操作主机 和 数据库
参考链接 http://www.cnblogs.com/top5/archive/2010/09/14/1825571.html ******** GRANT ALL ON push.* TO pus ...
- 源码|ThreadLocal的实现原理
ThreadLocal也叫"线程本地变量"."线程局部变量": 其作用域覆盖线程,而不是某个具体任务: 其"自然"的生命周期与线程的生命周期 ...
- 服务注册发现Eureka之二:高可用服务注册中心
前言 在Spring Cloud系列文章的开始,我们就介绍了服务注册与发现,其中,主要演示了如何构建和启动服务注册中心Eureka Server,以及如何将服务注册到Eureka Server中,但是 ...
- appium 5-27屏幕旋转、
1.屏幕切换 注意:应用一定要支持横竖屏切换,否则无效果, public void testBrowser() throws InterruptedException { Thread.sleep(1 ...
- 正则的使用及replace细讲
1.var reg=/./ 与 var reg=/\./的区别? .代表任意一个字符 \.而后者代表这个字符串中得有一个. 2.?的使用 如果单独的一个字符后面带? /\d?/ 代表1个或0个这个字符 ...
- javascript继承之借用构造函数(二)
//简单的函数调用 function Father() { this.nums= [1,2]; } function Son() { Father.call(this);//调用超类型,完成son继承 ...