擅长:python、mysql、java
<p>在没有更多上下文的情况下不知道缩进错误,但是可以做些什么来缩短<code>if</code>条件:</p>
<pre><code>lst = [h1, h2, h3, h4, h5, h6, h7, h8]
if h9 in lst and h10 in lst:
pass
</code></pre>
<p>另外,您应该使用更具描述性的变量名。</p>
<hr/>
<p>哦,如果你有很多元素并且计划进行大量搜索,你可能会喜欢集合:</p>
<pre><code>s = set([h1, h2, h3, h4, h5, h6, h7, h8]) # {h1, h2, h3, ...} in Python 3.x
if h9 in s and h10 in s:
pass
</code></pre>