擅长:python、mysql、java
<p>如果单位是<code>mbar</code>,但值是浮点值,则此检查也将是<code>False</code>:</p>
<pre><code>if(isinstance(pressure,int) and (unit == "pascal" or unit == "mbar" or unit == "atm" or unit == "torr")):
</code></pre>
<p>这就是为什么你会收到“不是一个可接受的单位”的信息。您需要分别检查这两件事:值是整数(yes/no)还是单位有效(yes/no)。如果两者都是这样,则可以打印成功消息。否则,您将需要独立打印一条或两条失败消息。你知道吗</p>