擅长:python、mysql、java
<p>简单的解决办法是</p>
<pre><code>if not uname and not passwd:
</code></pre>
<p>因为它的评估结果是</p>
^{pr2}$
<p>或者</p>
<pre><code>if not (uname or passwd):
</code></pre>
<p>但是,如果没有提供<code>uname</code>和{<cd2>},这将不会像等待的那样工作(它将打印所有三个)。在</p>
<p>您可以将逻辑更改为只执行一个<code>print</code>的构造:</p>
<pre><code>uname = ""
passwd = "jhj"
if not (uname or passwd):
print "either"
elif not uname:
print "uname"
elif not passwd:
print "passwd"
</code></pre>