擅长:python、mysql、java
<p>布尔<code>or</code>运算符通过按从左到右的顺序计算候选值,返回第一个出现的truthy值。所以在您的例子中,它首先用于打印<code>'Hello lambda world'</code>,因为它返回<code>None</code>(被认为是错误的),然后它将计算<code>sys.exit()</code>,从而结束程序。在</p>
<pre><code>lambda: print('Hello lambda world') or sys.exit()
</code></pre>
<hr/>
<p><a href="https://docs.python.org/3/reference/expressions.html#or" rel="nofollow noreferrer">Python Documentation</a>:</p>
<blockquote>
<p>The expression <code>x or y</code> first evaluates <code>x</code>; if <code>x</code> is true, its value is
returned; otherwise, <code>y</code> is evaluated and the resulting value is
returned.</p>
</blockquote>