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

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

    1. <tfoot id='cUl42'></tfoot>

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

      Python中的布尔“和"

      时间:2023-09-01
    2. <legend id='Go51t'><style id='Go51t'><dir id='Go51t'><q id='Go51t'></q></dir></style></legend>
        <tfoot id='Go51t'></tfoot>

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

                  <tbody id='Go51t'></tbody>

              • <small id='Go51t'></small><noframes id='Go51t'>

                本文介绍了Python中的布尔“和"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有人可以解释以下测试背后的原因吗??

                Can somebody explain the reasoning behind the following tests ??

                >>> 1 and True
                True
                >>> {'foo': 'Foo'} and True
                True
                >>> {} and True
                {}
                >>>
                

                推荐答案

                在布尔运算的上下文中,以及当控制流语句使用表达式时,以下值被解释为 false:False、None、数字零所有类型,以及空字符串和容器(包括字符串、元组、列表、字典、集合和frozensets).所有其他值都被解释为 true.

                In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). All other values are interpreted as true.

                表达式 x 和 y 首先计算 x;如果 x 为假,则返回其值;否则,计算 y 并返回结果值.

                The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is evaluated and the resulting value is returned.

                表达式 x 或 y 首先计算 x;如果 x 为真,则返回其值;否则,计算 y 并返回结果值.

                The expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned.

                如需进一步参考,请阅读有关布尔运算的更多信息:http://docs.python.org/reference/expressions.html#boolean-operations

                For further reference read more on Boolean operations: http://docs.python.org/reference/expressions.html#boolean-operations

                这篇关于Python中的布尔“和"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:pandas 数据框将 INT64 列转换为布尔值 下一篇:Python 2.x 中的 True=False 赋值

                相关文章

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

                    <tfoot id='lL3Md'></tfoot>

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

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