Python标准模块——__future__
2017-05-17 08:57
190 查看
Python 2.x和Python3.x有不少不相同的地方,直接将Python 2.7的代码移植到Python 3.x中需要进行大量修改。
而在Python 2.x中使用__future__模块可以仅进行少量修改就应用Python 3.x的一些特性。比如上面的除法示例:
division
在Python 2.x中两个整数相除会得到一个整数,是地板除,而Python 3.x中两个整数相除得到的是精确解,地板除用//。#Python 2.x >>>50 / 3 >16 #Python 3.x >>>50 / 3 >16.666666666666668 >>>50 // 3 >16
而在Python 2.x中使用__future__模块可以仅进行少量修改就应用Python 3.x的一些特性。比如上面的除法示例:
>>>from __future__ import division >>>50 / 3 >16.666666666666668
相关文章推荐
- Python的标准logging模块(2)
- Python的标准logging模块(4)
- 使用Python标准库中的wave模块绘制乐谱的简单教程
- Python 3.x标准模块库目录
- Python 3.x标准模块库目录
- Python模块之 __future__
- Python future模块小例子
- Python(2.7.6) 标准日志模块 - Logging Handler
- Python(2.7.6) 标准日志模块的简单示例
- python开发学习-day05(正则深入、冒泡排序算法、自定义模块、常用标准模块)
- Python的标准logging模块
- python的__future__模块
- Python的标准logging模块
- Python(2.7.6) 标准日志模块 - Logging Configuration
- python标准日志模块logging的使用方法
- Python的标准logging模块(3)
- Python: __future__模块
- Python 3.x标准模块库目录
- python标准日志模块logging的使用方法
- pythonday05(正则深入、冒泡排序算法、自定义模块、常用标准模块)