zoukankan      html  css  js  c++  java
  • from __future__ import division

    导入python未来支持的语言特征division(精确除法),当我们没有在程序中导入该特征时,"/"操作符执行的是截断除法(Truncating Division),当我们导入精确除法之后,"/"执行的是精确除法,如下所示:
    ---------------------------------------------------------------------------------------------

    >>> 3/4

    0

    >>> from __future__ import division

    >>> 3/4

    0.75

    --------------------------------------------------------------------------------------------

    导入精确除法后,若要执行截断除法,可以使用"//"操作符:
    --------------------------------------------------------------------------------------------
    >>> 3//4
    0
    --------------------------------------------------------------------------------------------
     
    一些将来特征如下:
    featureoptional inmandatory ineffect
    nested_scopes 2.1.0b1 2.2 PEP 227Statically Nested Scopes
    generators 2.2.0a1 2.3 PEP 255Simple Generators
    division 2.2.0a2 3.0 PEP 238Changing the Division Operator
    absolute_import 2.5.0a1 2.7 PEP 328Imports: Multi-Line and Absolute/Relative
    with_statement 2.5.0a1 2.6 PEP 343The “with” Statement
    print_function 2.6.0a2 3.0 PEP 3105Make print a function
    unicode_literals 2.6.0a2 3.0 PEP 3112Bytes literals in Python 3000
    PEP:Python Enhancement Proposals
    
    可以在这个地方找到很多PEP:http://www.python.org/dev/peps/ 里面还能看到许多提议的动机
    ----------------------------------------------------------------------------
    nested_scopes: 改变名空间的搜索过程
    generators:使用生成器.能够产生能保存当前状态的函数.
    division:精确的除法
    absolute_import:包含绝对路径.方便include
    with_statement:安全的打开文件
     
  • 相关阅读:
    addClass 函数
    Javascript 严格模式详解
    Animated Scroll to Top
    Cross-Browser HTML5 Placeholder Text
    不要滥用div,保持代码的整洁
    Revit二次开发示例:DeleteDimensions
    Revit二次开发示例:ChangesMonitor
    IEnumerable,ICollection,IList,List之间的区别
    Revit二次开发示例:CancelSave
    Revit二次开发示例:AutoUpdate
  • 原文地址:https://www.cnblogs.com/wjoyxt/p/4554477.html
Copyright © 2011-2022 走看看