from __future__ import print_function 用法 from __future__ import print_function 用法

original

from __future__ import print_function 用法

      版权声明:本文为博主原创文章,未经博主允许不得转载。          https://blog.csdn.net/xiaotao_1/article/details/79460365        </div>
        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
                          <div id="content_views" class="markdown_views">
        <!-- flowchart 箭头图标 勿删 -->
        <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
          <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
        </svg>
        <p>  在开头加上<code>from __future__ import print_function</code>这句之后,即使在python2.X,使用print就得像python3.X那样加括号使用。python2.X中print不需要括号,而在python3.X中则需要。</p>
# python2.7
print "Hello world"

# python3
print("Hello world")
  
  
  • 1
  • 2
  • 3
  • 4
  • 5

  If there is a new feature in a version, but this feature is not compatible with the current version and used, it is in this version is not the language standard, so if I want to use, then you need from future import module .

  Other
    from __future__ import divisionexamples:
    from __future__ import absolute_import,
    from __future__ import with_statement, . And so
  add these, if your python version python2.X, so you have to use these functions in accordance with python3.X.

      版权声明:本文为博主原创文章,未经博主允许不得转载。          https://blog.csdn.net/xiaotao_1/article/details/79460365        </div>
        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-f57960eb32.css">
                          <div id="content_views" class="markdown_views">
        <!-- flowchart 箭头图标 勿删 -->
        <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
          <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
        </svg>
        <p>  在开头加上<code>from __future__ import print_function</code>这句之后,即使在python2.X,使用print就得像python3.X那样加括号使用。python2.X中print不需要括号,而在python3.X中则需要。</p>

Guess you like

Origin blog.csdn.net/j879159541/article/details/90765195