擅长:python、mysql、java
<pre><code>def f(lst):
# if you want the exact same filtering as the original, you could use
# lst = [item for item in lst if (item is not None and item != 0)]
lst = [item for item in lst if item]
if lst: return min(lst)
else: return None
</code></pre>
<p>列表理解只允许不计算为布尔值false的项(它过滤掉0和None)</p>
<p>空列表(即.[]将计算为False),因此“if lst:”将仅在列表具有项时触发</p>