<tfoot id='PjDsj'></tfoot>
      • <bdo id='PjDsj'></bdo><ul id='PjDsj'></ul>

    1. <i id='PjDsj'><tr id='PjDsj'><dt id='PjDsj'><q id='PjDsj'><span id='PjDsj'><b id='PjDsj'><form id='PjDsj'><ins id='PjDsj'></ins><ul id='PjDsj'></ul><sub id='PjDsj'></sub></form><legend id='PjDsj'></legend><bdo id='PjDsj'><pre id='PjDsj'><center id='PjDsj'></center></pre></bdo></b><th id='PjDsj'></th></span></q></dt></tr></i><div id='PjDsj'><tfoot id='PjDsj'></tfoot><dl id='PjDsj'><fieldset id='PjDsj'></fieldset></dl></div>
      <legend id='PjDsj'><style id='PjDsj'><dir id='PjDsj'><q id='PjDsj'></q></dir></style></legend>

      <small id='PjDsj'></small><noframes id='PjDsj'>

        Python 将 0 评估为 False

        Python evaluates 0 as False(Python 将 0 评估为 False)
        <tfoot id='j65oL'></tfoot>

          <legend id='j65oL'><style id='j65oL'><dir id='j65oL'><q id='j65oL'></q></dir></style></legend>

            <bdo id='j65oL'></bdo><ul id='j65oL'></ul>

              <small id='j65oL'></small><noframes id='j65oL'>

                <i id='j65oL'><tr id='j65oL'><dt id='j65oL'><q id='j65oL'><span id='j65oL'><b id='j65oL'><form id='j65oL'><ins id='j65oL'></ins><ul id='j65oL'></ul><sub id='j65oL'></sub></form><legend id='j65oL'></legend><bdo id='j65oL'><pre id='j65oL'><center id='j65oL'></center></pre></bdo></b><th id='j65oL'></th></span></q></dt></tr></i><div id='j65oL'><tfoot id='j65oL'></tfoot><dl id='j65oL'><fieldset id='j65oL'></fieldset></dl></div>
                    <tbody id='j65oL'></tbody>
                  本文介绍了Python 将 0 评估为 False的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Python 控制台中:

                  In the Python console:

                  >>> a = 0
                  >>> if a:
                  ...   print "L"
                  ... 
                  >>> a = 1
                  >>> if a:
                  ...   print "L"
                  ... 
                  L
                  >>> a = 2
                  >>> if a:
                  ...   print "L"
                  ... 
                  L
                  

                  为什么会这样?

                  推荐答案

                  在Python中,boolint的子类,False值为 0;即使值没有在 if 语句(它们是)中隐式转换为 boolFalse == 0 也是 true.

                  In Python, bool is a subclass of int, and False has the value 0; even if values weren't implicitly cast to bool in an if statement (which they are), False == 0 is true.

                  这篇关于Python 将 0 评估为 False的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)

                    <small id='ryl6G'></small><noframes id='ryl6G'>

                      <bdo id='ryl6G'></bdo><ul id='ryl6G'></ul>

                            <tfoot id='ryl6G'></tfoot>
                          • <i id='ryl6G'><tr id='ryl6G'><dt id='ryl6G'><q id='ryl6G'><span id='ryl6G'><b id='ryl6G'><form id='ryl6G'><ins id='ryl6G'></ins><ul id='ryl6G'></ul><sub id='ryl6G'></sub></form><legend id='ryl6G'></legend><bdo id='ryl6G'><pre id='ryl6G'><center id='ryl6G'></center></pre></bdo></b><th id='ryl6G'></th></span></q></dt></tr></i><div id='ryl6G'><tfoot id='ryl6G'></tfoot><dl id='ryl6G'><fieldset id='ryl6G'></fieldset></dl></div>
                            <legend id='ryl6G'><style id='ryl6G'><dir id='ryl6G'><q id='ryl6G'></q></dir></style></legend>

                              <tbody id='ryl6G'></tbody>