<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中的布尔“和"

      boolean #39;and#39; in Python(Python中的布尔“和)
    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中的布尔“和"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 与否?)

                          <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>
                            <tbody id='lL3Md'></tbody>