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 “ ” ...
随机推荐
- install kde in ubuntu
http://www.arthurtoday.com/2012/08/ubuntu-12.04-install-kde-4.9.html sudo apt-get install kubuntu-de ...
- openwrt lamp
https://applefreak111.wordpress.com/2013/03/12/howtoopenwrt-lamp-stack%E5%AE%89%E8%A3%9D/ opkg updat ...
- Callable接口和Future
本篇说明的是Callable和Future,它俩很有意思的,一个产生结果,一个拿到结果. Callable接口类似于Runnable,从名字就可以看出来了,但是Runnable不会返回结 ...
- [UE4]FString常用API
转自:http://aigo.iteye.com/blog/2279808 将int或float转换为string: 将FString转换为char*: 将string转换为int或者float: 字 ...
- 第3课 进化后的 const分析
1. C语言中的const (1)const修饰的变量是只读的,使得变量具有只读属性,但本质还是变量.所以不是真正的常量,它只是告诉编译器该变量不能出现在赋值符号的左边. (2)const修饰的局部 ...
- 【Unix网络编程】chapter6 IO复用:select和poll函数
chapter6 6.1 概述 I/O复用典型使用在下列网络应用场合. (1):当客户处理多个描述符时,必须使用IO复用 (2):一个客户同时处理多个套接字是可能的,不过不叫少见. (3):如果一个T ...
- Windows Event 事件
事件对象就像一个开关:它只有两种状态(开和关). 开状态:我们称其为“有信号” 关状态:我们称其为“无信号” 可以在一个线程的执行函数中创建一个事件对象,然后观察它的状态,如果是“无信号”就让该线程睡 ...
- Spark分析之TaskScheduler
TaskScheduler概述: TaskScheduler是一个可插拔任务调度接口,通过不同的SchedulerBackend进行任务的调度.主要功能如下: 1.一个TaskScheduler只为一 ...
- 教Alexa看懂手语,不说话也能控制语音助手
Alexa.Siri.小度……各种语音助手令人眼花缭乱,但这些设备多是针对能力健全的用户,忽略了听.说能力存在障碍的人群.本文作者敏锐地发现了这一 bug,并训练亚马逊语音助手 Alex 学会识别美式 ...
- django中使用Ajax
内容: 1.Ajax原理与基本使用 2.Ajax发送get请求 3.Ajax发送post请求 4.Ajax上传文件 5.Ajax设置csrf_token 6.django序列化 参考:https:// ...