<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

        时间:2023-09-01
        <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python中布尔表达式的求值 下一篇:Python 中的“x = y 或 z"赋值有什么作用?

                  相关文章

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

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

                      <tfoot id='ryl6G'></tfoot>
                    1. <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>